Audited ·Last updated 28 Jul 2026·4 citations·Tier 2·0 uses

CIDR to Subnet Mask Converter

Convert a CIDR prefix to a subnet mask or a subnet mask back to a prefix. Shows the wildcard, binary and hexadecimal masks and the address counts.

CIDR to Subnet Mask Converter

What do you have?
Used in prefix-to-mask mode. The number after the slash in CIDR notation — the count of leading 1-bits in the mask, 0 to 32.
Used in mask-to-prefix mode. Dotted decimal, with contiguous left-aligned 1-bits: 255.255.255.192 is valid, 255.0.255.0 is not.
Subnet mask
255.255.255.192
The dotted-decimal mask: the prefix count of leading 1-bits followed by zeros, exactly as RFC 4632 describes the prefix-to-mask relationship.
Prefix length
26
CIDR suffix
/26
Wildcard (inverse) mask
0.0.0.63
Binary mask
11111111.11111111.11111111.11000000
Hexadecimal mask
0xFFFFFFC0
Addresses in the block
64
Usable host addresses
62

Background.

Two notations describe the same 32 bits, and network equipment is inconsistent about which one it wants. A cloud console asks for 10.0.0.0/16. A Windows adapter dialog asks for 255.255.0.0. A Cisco access list asks for 0.0.255.255. A packet capture prints 0xFFFF0000. This converter moves between all four, in both directions, without asking you for an IP address.

That last point is the design decision worth stating. Most subnet tools insist on an address before they will tell you anything, but the mask is a property of the prefix alone: /26 is 255.255.255.192 whether you are working in 10.x, 172.16.x or 192.168.x. When your question is "what mask is /26?" or the reverse, "255.255.254.0 — what prefix is that?", an address field is friction and the reverse direction is not even possible on a tool built around one. If your question is instead "which network does 192.168.10.37/26 belong to, and what host addresses can I use?", that is address-dependent and belongs on the companion IP subnet calculator, which this page links to.

The underlying relationship is defined in RFC 4632, the current CIDR specification. A prefix is written as a four-octet quantity followed by a slash and "a decimal value between 0 and 32 that describes the number of significant bits", and the corresponding mask is "a 32-bit value where the most significant 16 bits are ones and the least significant 16 bits are zeros" for the /16 case. Set the first p bits to one, the remaining 32 − p to zero, and read the result out eight bits at a time. That is the whole conversion. RFC 1878 tabulated every row of it back in 1995, and the numbers this page returns match that table.

Mask validity matters in the reverse direction. RFC 950, which introduced the address mask, recommended "that the subnet bits be contiguous and located as the most significant bits of the local address", and CIDR's prefix model makes contiguity mandatory — a prefix length simply cannot express a mask with holes in it. So 255.255.255.192 is a valid mask and 255.0.255.0 is not, and neither is 255.255.255.253, whose last octet is 11111101. This converter rejects both rather than inventing a prefix for them.

The address counts come with one standards-driven wrinkle. For any prefix of /30 or shorter, two addresses per block are reserved — the all-zeros network address and the all-ones broadcast address — so a /24 holds 256 addresses but only 254 hosts. At /31 that rule stops: RFC 3021 permits 31-bit prefixes on point-to-point links, where "only two possible addresses may result" and both "MUST be interpreted as host addresses". A /31 therefore has 2 usable hosts, not zero, and a /32 host route has exactly 1. Tools that apply the minus-two rule to every prefix report 0 and −1 for these two cases, which is a real and frequently copied error.

Everything here is IPv4. IPv6 uses the same slash notation over 128 bits with no broadcast address and different conventions entirely, so it is not folded into this page.

What is cidr to subnet mask converter?

A subnet mask is a 32-bit value whose leading bits are ones across the network portion of an address and zeros across the host portion. A CIDR prefix length is the count of those leading one bits. They are two spellings of one fact: /26 and 255.255.255.192 both say "the first 26 bits identify the network".

RFC 950 introduced the mask form in 1985, instructing implementations to "use a bit mask ('address mask') to identify which bits of the local address field indicate the subnet number" and recommending that those bits be contiguous and left-aligned. RFC 4632 later replaced classful addressing with the prefix form, which can only express contiguous left-aligned masks — so the recommendation became a requirement in practice.

The wildcard mask, sometimes called the inverse mask, is the bitwise complement: where the subnet mask has a one, the wildcard has a zero. Cisco IOS access lists and OSPF network statements are written with wildcard masks, which is why 192.168.10.0 0.0.0.255 in a config means the same block as 192.168.10.0/24. Getting the two forms confused is one of the most common configuration errors in access-list work, which is why both are shown side by side here.

How to use this calculator.

  1. Choose which direction you need: you have a prefix and want the mask, or you have a mask and want the prefix.
  2. In prefix-to-mask mode, enter the number after the slash — 0 to 32. The mask field is ignored.
  3. In mask-to-prefix mode, enter the dotted-decimal mask. The prefix field is ignored. Masks with non-contiguous bits are rejected with an explanation rather than silently accepted.
  4. Copy the wildcard mask when you are writing a Cisco-style access list or an OSPF network statement — those take the inverse form, not the subnet mask.
  5. Use the binary mask to see the boundary directly. Counting the ones is the fastest way to sanity-check a mask you were handed verbally.
  6. Check the usable-hosts figure before you commit to a prefix. A /29 holds 8 addresses but only 6 hosts, and the gateway takes one of those.
  7. If you also need the network address, broadcast address and host range for a specific IP, use the IP subnet calculator instead — it takes an address, which this page deliberately does not.

The formula.

mask = 2^32 − 2^(32−p) · wildcard = 2^(32−p) − 1

Start from the block size: a prefix of p leaves 32 − p host bits, so the block holds 2^(32−p) addresses. The mask as a 32-bit unsigned integer is 2^32 − blockSize, which is arithmetically identical to p ones followed by 32 − p zeros. Converting that integer to dotted decimal is repeated division by 256, most significant octet first.

For /26: blockSize = 2^6 = 64; mask = 4,294,967,296 − 64 = 4,294,967,232; dividing that down by 256 four times yields the octets 255, 255, 255, 192 — the mask 255.255.255.192.

The wildcard mask is the complement, 2^32 − 1 − mask, which simplifies to blockSize − 1. For /26 that is 63, or 0.0.0.63. The binary form is the same 32 bits printed as four groups of eight; the hexadecimal form is the same four octets printed as two hex digits each, giving 0xFFFFFFC0.

The reverse direction parses the dotted-decimal mask into its 32-bit value m and computes blockSize = 2^32 − m. The mask is valid only if that block size is an exact power of two, which is the arithmetic statement of "the 1-bits are contiguous and left-aligned". The prefix is then the exponent: 32 − log2(blockSize), found by an exact integer search rather than a floating-point logarithm so that no rounding can shift the answer by one bit. A mask like 255.0.255.0 produces a block size that is not a power of two and is rejected.

Host counting branches at the top of the range. Below /31, the network and broadcast addresses are reserved, so usable = blockSize − 2. At /31, RFC 3021 makes both addresses host addresses on a point-to-point link, so usable = 2. At /32 there is one address and one usable host.

All arithmetic is performed on exact integers rather than with JavaScript's bitwise operators, which coerce their operands to signed 32-bit values — under those operators 0xFFFFFFC0 evaluates to −64, and every mask shorter than /32 comes out negative.

A worked example.

Example

You have been handed a block written as /26 and the firewall you are configuring only accepts a dotted-decimal mask. The block size is 2^(32−26) = 2^6 = 64 addresses. The mask as an integer is 2^32 − 64 = 4,294,967,296 − 64 = 4,294,967,232. Dividing that down by 256 four times gives the octets: 4,294,967,232 mod 256 = 192, then 16,777,215 mod 256 = 255, then 65,535 mod 256 = 255, then 255 — so the mask is 255.255.255.192. In binary that is 11111111.11111111.11111111.11000000: twenty-six ones, then six zeros, exactly matching the prefix. The hexadecimal form is 0xFFFFFFC0, since 192 is 0xC0. The wildcard mask is the complement, blockSize − 1 = 63, or 0.0.0.63 — that is the form you would use in a Cisco access-list line. The block holds 64 addresses, of which 62 are usable hosts once the network and broadcast addresses are reserved. Running the same numbers backwards confirms the pair: entering 255.255.255.192 in mask-to-prefix mode gives 2^32 − 4,294,967,232 = 64 = 2^6, an exact power of two, so the prefix is 32 − 6 = 26.

modeprefixToMask
prefix Length26
subnet Mask255.255.255.192

Frequently asked questions.

What subnet mask is /24?
255.255.255.0. The prefix fixes the first 24 bits, so the mask is twenty-four ones followed by eight zeros: 11111111.11111111.11111111.00000000. The block holds 2^8 = 256 addresses, of which 254 are usable hosts after the network and broadcast addresses are reserved. RFC 1878's variable-length subnet table lists exactly this row. The matching wildcard mask, used in Cisco access lists, is 0.0.0.255.
What is the difference between a subnet mask and a wildcard mask?
They are bitwise complements of each other. A subnet mask has ones where the network portion is (255.255.255.0 for a /24); the wildcard mask has zeros there and ones over the host portion (0.0.0.255 for the same /24). Cisco IOS access lists and OSPF network statements take the wildcard form, while interface configuration and most other vendors take the subnet mask form. Mixing them up is a classic access-list bug: 192.168.1.0 255.255.255.0 in an ACL does not mean what 192.168.1.0 0.0.0.255 means.
Why is 255.0.255.0 rejected as a subnet mask?
Because its 1-bits are not contiguous, and a CIDR prefix length can only describe a mask whose ones are contiguous and left-aligned. RFC 950 already recommended "that the subnet bits be contiguous and located as the most significant bits of the local address", and RFC 4632's prefix model makes that structural: there is no number p for which 255.0.255.0 is p ones followed by zeros. Some very old equipment tolerated discontiguous masks; nothing modern does. 255.255.255.253 is rejected for the same reason — its last octet is 11111101.
Why does a /31 show 2 usable hosts instead of 0?
Because RFC 3021 defines it that way for point-to-point links. With a 31-bit prefix "only two possible addresses may result" and both "MUST be interpreted as host addresses" — there is no broadcast address to reserve on a link where every frame reaches exactly one peer. Applying the usual minus-two rule would give zero usable hosts. RFC 3021 notes the practical benefit: a network with 500 point-to-point links saves 1,000 addresses by using /31 instead of /30.
How do I work out the prefix from a mask in my head?
Count the ones. Each 255 octet contributes 8 bits, so 255.255.255.x starts you at 24. Then decode the last non-zero octet: 128 = 1 bit, 192 = 2, 224 = 3, 240 = 4, 248 = 5, 252 = 6, 254 = 7, 255 = 8. So 255.255.255.192 is 24 + 2 = /26, and 255.255.254.0 is 16 + 7 = /23. Those eight values are the only legal non-zero, non-255 octets in a mask — anything else has non-contiguous bits.
What is the hexadecimal mask for?
Kernel routing tables, packet captures and BSD-style tooling frequently print masks in hex. 0xFFFFFF00 is /24, 0xFFFFFFC0 is /26, 0xFFFFFFFF is /32. It is also the fastest form to eyeball when debugging: each hex digit is exactly four bits, so a mask ending in C0 is unmistakably two extra network bits beyond the octet boundary.
Does this work for IPv6?
No. This converter is IPv4-only, over a 32-bit address space with prefixes from /0 to /32. IPv6 uses the same slash notation over 128 bits, does not use dotted-decimal masks at all, has no broadcast address, and conventionally assigns a /64 to every host subnet regardless of device count. The two would need contradictory rules under the same output labels, so IPv6 is deliberately out of scope here.
Where do I get the network address and host range?
From the IP subnet calculator, which is the companion to this page. Those three facts — network address, broadcast address and usable host range — depend on which address you are looking at, not just on the prefix, so they need an IP address as an input. This page deliberately takes no address, because the mask, wildcard, binary and hexadecimal forms are properties of the prefix alone and asking for an address to obtain them would be pure friction.

References& sources.

  1. [1]Fuller, V. & Li, T. (2006). RFC 4632, "Classless Inter-domain Routing (CIDR): The Internet Address Assignment and Aggregation Plan". IETF BCP 122. Defines the slash notation as "a decimal value between 0 and 32 that describes the number of significant bits" and states that /16 corresponds to a mask "where the most significant 16 bits are ones and the least significant 16 bits are zeros" — the exact relationship implemented by this converter.
  2. [2]Pummill, T. & Manning, B. (1995). RFC 1878, "Variable Length Subnet Table For IPv4". The canonical prefix-to-mask table: /24 = 255.255.255.0 = 256 addresses, /30 = 255.255.255.252 = 4 addresses, /31 = 255.255.255.254 = 2 addresses, /32 a single host route. The address counts include the network and broadcast addresses, matching this page's "addresses in the block" output.
  3. [3]Mogul, J. & Postel, J. (1985). RFC 950, "Internet Standard Subnetting Procedure". Introduces the address mask — "use a bit mask ('address mask') to identify which bits of the local address field indicate the subnet number" — and recommends "that the subnet bits be contiguous and located as the most significant bits of the local address", the rule this converter enforces when validating a mask.
  4. [4]Retana, A., White, R., Fuller, V. & McPherson, D. (2000). RFC 3021, "Using 31-Bit Prefixes on IPv4 Point-to-Point Links". States that a 31-bit prefix yields "only two possible addresses" which "MUST be interpreted as host addresses" — the basis for reporting 2 usable hosts at /31 rather than 0.

In this category

Embed

Quanta Pro

Paid features are coming later.

  • All 590 calculators remain free
  • No billing is enabled
Coming soon