IP subnet mask calculator
Enter an IP address and prefix length to calculate the subnet mask, network address, broadcast address, and the full range of usable host addresses.
/24 · 255.255.255.0 · 254 usable hosts
How it works
The tool parses the CIDR notation using pure JavaScript bit arithmetic. The prefix length determines the subnet mask; bitwise AND gives the network address; bitwise OR of the inverted mask gives the broadcast address. All host range calculations follow from there.
Processing runs in your browser
All calculations happen locally in the page. Our servers are not involved at any point.
Technical specification
Classless Inter-Domain Routing (CIDR) is defined in RFC 4632 (IETF, 2006). CIDR notation expresses an IPv4 network as address/prefix where the prefix length (0–32) specifies how many leading bits constitute the network portion. The subnet mask is derived by setting the top n bits to 1 and the remaining 32 − n bits to 0. Network address = address AND mask; broadcast = address OR (NOT mask). IPv6 CIDR follows the same principles with 128-bit addresses per RFC 4291.
- Standard
- RFC 4632. Classless Inter-domain Routing (CIDR)
- Address space (IPv4)
- 32-bit; /24 = 256 addresses, /16 = 65,536
- Subnet mask derivation
- Top n bits = 1, remaining 32 − n bits = 0
- Usable hosts
- 2^(32−prefix) − 2 (network + broadcast reserved)
Related operations
For working with file permission bits, try the chmod calculator. To convert IP octets between binary and decimal, use the number base converter. For converting between KB, MB, and GB in transfer planning, see the byte converter.
Frequently asked questions
- What is a subnet mask?
- A subnet mask is a 32-bit number that separates the network portion of an IP address from the host portion. For a /24 network, the subnet mask is 255.255.255.0, the first 24 bits are all 1s.
- What are common subnet masks?
- /8 = 255.0.0.0 (Class A, ~16M hosts), /16 = 255.255.0.0 (Class B, ~65K hosts), /24 = 255.255.255.0 (Class C, 254 hosts), /32 = 255.255.255.255 (single host).
- How do I find the subnet mask for a given prefix length?
- The prefix length /n means the first n bits of the 32-bit mask are 1, and the rest are 0. For example, /24 gives 11111111.11111111.11111111.00000000 in binary, which is 255.255.255.0 in decimal.