IP Range to CIDR Converter

Turn any address range into the fewest CIDR blocks that cover it exactly, plus why trimming a /24’s two ends turns it into fourteen.

The blocks are the fewest that cover the range exactly — no address outside it, none missed inside. Nothing is uploaded.

A range that looks like one block usually is not

192.168.1.0 to 192.168.1.255 is a single /24. Trim the two end addresses — exactly what a rule does when it excludes the network and broadcast — and 192.168.1.1 to 192.168.1.254 needs 14 blocks. Nothing got complicated; the range just stopped starting and ending on power-of-two boundaries, and CIDR can only express blocks that do.

RangeAddressesBlocks
a clean /24
192.168.1.0 – 192.168.1.255
256 1
the same, minus both ends
192.168.1.1 – 192.168.1.254
254 14
eleven addresses
10.0.0.0 – 10.0.0.10
11 3
one address
10.0.0.7 – 10.0.0.7
1 1
a DHCP pool
10.0.0.100 – 10.0.0.199
100 5
the whole space, minus both ends
0.0.0.1 – 255.255.255.254
4,294,967,294 62

The worst case is exactly 62

Every block must start on its own boundary, so covering a range means climbing powers of two up from the start and back down to the end — at most 31 blocks on each side. That bound of 2 × 32 − 2 is not just approached, it is reached: 0.0.0.1 through 255.255.255.254 needs exactly 62.

BlockPrefixAddresses
192.168.1.1 /32 1
192.168.1.2 /31 2
192.168.1.4 /30 4
192.168.1.8 /29 8
192.168.1.16 /28 16
192.168.1.32 /27 32
192.168.1.64 /26 64
192.168.1.128 /26 64
192.168.1.192 /27 32
192.168.1.224 /28 16
192.168.1.240 /29 8
192.168.1.248 /30 4
192.168.1.252 /31 2
192.168.1.254 /32 1

The shape is the giveaway. The prefixes run 32 31 30 29 28 27 26 26 27 28 29 30 31 32 — blocks growing from a single address up to the largest that fits, then shrinking back down. The two equal prefixes in the middle are where the climb meets the descent, and that plateau is why a strict "rises then falls" test on this sequence fails: it has to allow the two to be equal.

Edges

A block converted to a range and back is the same block, at every prefix from /8 to /32. A single address comes out as a /32. A range whose end precedes its start produces nothing rather than looping, and a range running to 255.255.255.255 terminates rather than wrapping past the top of the space — which is the arithmetic that most hand-rolled versions of this get wrong, because the obvious loop increments past the last address and starts again at zero.

How to use

  1. Enter the first and last address of the range.
  2. Read the blocks that cover it exactly.
  3. Each block shows its own range and size.
  4. Note how many it takes — it is rarely one.

Frequently asked questions

Why does my range need more than one block?

Because a CIDR block must begin on its own power-of-two boundary and be a power of two long. A range that starts or ends anywhere else cannot be written as a single prefix, so it has to be covered by several — climbing in size from the start and back down to the end.

How many blocks can a range need?

Up to 62 for IPv4, which is 2 × 32 − 2. That bound is not merely approached, it is reached: 0.0.0.1 through 255.255.255.254 — the whole space with one address shaved off each end — needs exactly 62 blocks.

Why does trimming two addresses cost so much?

192.168.1.0 to 192.168.1.255 is one clean /24. Take off the network and broadcast addresses, which is what a firewall rule does routinely, and 192.168.1.1 to 192.168.1.254 needs fourteen blocks. Nothing about the range got complicated; it just stopped landing on boundaries.

Are these the fewest blocks possible?

Yes. The greedy choice — the largest block that both starts on its own boundary and does not run past the end — is optimal here, because a bigger block would have to start earlier or finish later and neither is available.

What shape do the blocks take?

They grow from the start and shrink toward the end, often with two equal-sized blocks in the middle where the climb meets the descent. A trimmed /24 runs /32 /31 /30 /29 /28 /27 /26 /26 /27 /28 /29 /30 /31 /32 — symmetric around that pair.

What about a single address?

It comes out as a /32, which is a block of exactly one. That is the smallest prefix there is and the reason a single host route is written that way.

Does this send anything anywhere?

No. Everything is computed in your browser, and nothing is uploaded.

🔒 This tool runs entirely in your browser. Nothing you enter is uploaded, logged, or stored.