Network Tools
Subnet mask to binary.
Enter a subnet mask as 255.255.255.0, /24 or binary and see it in binary with its CIDR prefix, wildcard mask and host count. Add an IP address to watch the AND step that finds the network. Runs in your browser.
Input
Result
Enter a value, then press Calculate.
How a subnet mask works in binary
- A mask is 32 bits: a run of 1s on the left followed by 0s. The number of 1s is the CIDR prefix length, so 255.255.255.0 =
11111111.11111111.11111111.00000000= /24. - 1s mark the network part, 0s mark the host part. ANDing an address with the mask keeps the network bits and zeroes the host bits, which gives the network address.
- The 1s must be contiguous. A value like 255.0.255.0 is not a valid CIDR mask (RFC 4632).
- Host count: a prefix of /p has 232-p addresses. Normally the first (network) and last (broadcast) are not usable, so a /24 has 254 usable hosts. A /31 has 2 usable addresses on point-to-point links (RFC 3021) and a /32 is a single host.
- Wildcard mask: the mask with every bit flipped (0.0.0.255 for /24). It is the inverse form that some router access lists use.
Common masks
| Prefix | Dotted decimal | Binary | Addresses | Usable |
|---|---|---|---|---|
| /8 | 255.0.0.0 | 11111111.00000000.00000000.00000000 | 16777216 | 16777214 |
| /16 | 255.255.0.0 | 11111111.11111111.00000000.00000000 | 65536 | 65534 |
| /24 | 255.255.255.0 | 11111111.11111111.11111111.00000000 | 256 | 254 |
| /25 | 255.255.255.128 | 11111111.11111111.11111111.10000000 | 128 | 126 |
| /26 | 255.255.255.192 | 11111111.11111111.11111111.11000000 | 64 | 62 |
| /27 | 255.255.255.224 | 11111111.11111111.11111111.11100000 | 32 | 30 |
| /28 | 255.255.255.240 | 11111111.11111111.11111111.11110000 | 16 | 14 |
| /29 | 255.255.255.248 | 11111111.11111111.11111111.11111000 | 8 | 6 |
| /30 | 255.255.255.252 | 11111111.11111111.11111111.11111100 | 4 | 2 |
Example: 192.168.1.130 with /26 (255.255.255.192) gives network 192.168.1.128 and broadcast 192.168.1.191. For a full subnet plan use the IP Subnet / CIDR Calculator; for single addresses see IP Address to Binary and Binary to IP Address; for numbers in general the Binary Converter.
If you enter a wildcard mask such as 0.0.0.255, the tool recognises it and shows the subnet mask it corresponds to. Everything runs in your browser.
FAQ
What is 255.255.255.0 in binary?
11111111.11111111.11111111.00000000. That is 24 ones followed by 8 zeros, so the CIDR prefix is /24.
How do I convert a subnet mask to CIDR?
Convert each octet to binary and count the 1 bits. 255.255.255.192 is 11111111.11111111.11111111.11000000, which has 26 ones, so it is /26.
What is a wildcard mask?
The subnet mask with every bit flipped. For 255.255.255.0 the wildcard mask is 0.0.0.255. It is used where a device matches addresses by the bits that may vary.
Why is 255.0.255.0 rejected as a CIDR mask?
CIDR masks must have all their 1 bits together on the left (RFC 4632). A mask with 1s after a 0 cannot be written as a /prefix.
How many hosts fit in a /24, /30, /31 and /32?
A /24 has 256 addresses and 254 usable hosts, a /30 has 4 addresses and 2 usable hosts, a /31 has 2 addresses that are both usable on a point-to-point link (RFC 3021), and a /32 is one address.
Sources
- RFC 4632, Classless Inter-domain Routing (CIDR) (prefix notation; mask must be left contiguous)
- RFC 3021, Using 31-Bit Prefixes on IPv4 Point-to-Point Links
- RFC 950, Internet Standard Subnetting Procedure (subnet masks)
Sources retrieved October 2026.