What is a CIDR to Subnet Mask Converter?
CIDR (Classless Inter-Domain Routing) notation describes an IPv4 network with a prefix length such as /24. This converter turns that prefix into the equivalent dotted-decimal subnet mask (for example, /24 becomes 255.255.255.0) and reports how many addresses and usable hosts the subnet contains. It works for every IPv4 prefix from /0 to /32.
How to use it
Enter the CIDR prefix length (the number after the slash) between 0 and 32 and the tool instantly displays the matching subnet mask plus the total address count and usable host count. To reverse the process — going from a mask back to CIDR — simply count the number of consecutive leading 1 bits in the mask: 255.255.255.0 is 24 leading ones, so it is /24.
The formula explained
An IPv4 address is 32 bits. A /n network sets the first n bits to 1 (the network portion) and the rest to 0 (the host portion). The numeric mask value is therefore \(2^{32} - 2^{(32-n)}\). Splitting that 32-bit number into four 8-bit groups gives the familiar dotted-decimal octets. The number of host slots in the block is \(2^{(32-n)}\), and subtracting 2 (the network and broadcast addresses) yields the usable hosts.
$$\text{Mask} = 2^{32} - 2^{\left(32 - \text{Prefix}\right)} \quad,\quad \text{Total} = 2^{\left(32 - \text{Prefix}\right)}$$
Worked example
For /26:
$$2^{32} - 2^{\left(32 - 26\right)} = 4{,}294{,}967{,}296 - 64 = 4{,}294{,}967{,}232$$In binary that is 11111111.11111111.11111111.11000000, which is 255.255.255.192. The block holds \(2^{6} = 64\) addresses, giving \(64 - 2 = 62\) usable hosts.
FAQ
What does /32 mean? A /32 represents a single host (one address) with mask 255.255.255.255 and zero usable hosts.
Why are usable hosts 2 fewer than total addresses? The first address identifies the network and the last is the broadcast address, so neither can be assigned to a device.
Is this for IPv4 or IPv6? This converter is for IPv4 (32-bit) subnet masks. IPv6 uses prefix lengths up to /128 and does not use dotted-decimal masks.