IP Range to CIDR

Type the first and last address of a range. You get the fewest CIDR blocks that cover exactly those addresses, no more and no less, ready to paste into a firewall rule.

How it works

Firewalls, cloud security groups and allow lists usually take CIDR blocks, such as 10.0.0.0/24, not ranges such as 10.0.0.5 to 10.0.0.70. A CIDR block always has a size that is a power of two and starts on a multiple of that size, so most ranges need several blocks.

The converter starts at the first address and takes the biggest block that both starts there and does not run past the end. Then it moves to the next address after that block and repeats. This greedy method gives the fewest possible blocks.

Each block is listed with the addresses it covers, and the whole set is given one per line and comma-separated for pasting. Everything runs on this page.

How to use it

  1. 1 Type the first address of the range.
  2. 2 Type the last address. The blocks appear as you type.
  3. 3 Check the addresses each block covers in the line under it.
  4. 4 Copy one block, the one-per-line list or the comma-separated list.

Good to know

  • A range that starts on a round boundary and holds a power-of-two number of addresses is one block. 10.0.0.0 to 10.0.0.255 is just 10.0.0.0/24.
  • Ranges that start or end on odd addresses need the most blocks, sometimes dozens. That is normal, not a bug.
  • The blocks cover the range exactly, so nothing outside it is let in by accident.
  • Both ends are included: 10.0.0.5 to 10.0.0.5 is the single block 10.0.0.5/32.

Browser support

  • Chrome 94 and later
  • Firefox 93 and later
  • Safari 16.4 and later
  • Edge 94 and later

These are the oldest versions with everything the tool uses. They are worked out from the tool itself, so they change when it does.

Version numbers checked on 2026-09-04.

Turning 192.168.1.10 to 192.168.1.20 into four CIDR blocks

A CIDR block is a run of addresses with two rules. Its size is a power of two (1, 2, 4, 8 and up), and it starts on a multiple of its own size. A block of 4 can start at .8 or .12 but not at .10. A range you are handed, from a vendor or a log, follows neither rule, so the job is to cover it with blocks that do, and to use as few as possible.

Work through 192.168.1.10 to 192.168.1.20 by hand, looking only at the last number, 10 to 20. That is 11 addresses. Start at 10. The biggest block that may start at 10 is size 2, because 10 is a multiple of 2 but not of 4. A block of 2 covers 10 and 11, which is inside the range, so the first block is 192.168.1.10/31. A /31 is 32 minus 1 bits of network, which is a block of 2.

Next is 12. Twelve is a multiple of 4 but not 8, so the biggest block that can start there is 4, covering 12 to 15. That fits, so the second block is 192.168.1.12/30. Next is 16, a multiple of 16. A block of 16 would run to 31, and one of 8 would run to 23, both past 20. A block of 4 runs 16 to 19, which fits: 192.168.1.16/30. Last is 20. A block of 4 or 2 would run past 20, so it is a single address, 192.168.1.20/32.

Four blocks: 192.168.1.10/31, 192.168.1.12/30, 192.168.1.16/30 and 192.168.1.20/32. Add up their sizes, 2 + 4 + 4 + 1, and you get the 11 addresses you started with, with none outside the range. Type the two addresses into the boxes above and the same four blocks appear, each with the addresses it covers written under it.

The greedy rule, take the biggest block that is aligned and fits, always gives the fewest blocks, which is why firewall vendors and the standard libraries of Python and Go use it. It also shows why a range like 0.0.0.1 to 255.255.255.254 needs 62 blocks: it starts and ends one address away from a perfect /0, and each edge costs one block per bit.

The limits are simple. This page converts IPv4 ranges; IPv6 ranges are not supported here yet. It covers one range at a time, so to merge several overlapping ranges, convert each and deduplicate. And a CIDR list is only as good as the range you give it: check that the range you were sent is really inclusive at both ends, because an "end" address that someone meant as exclusive adds one address too many.

Frequently asked questions

Why do I get several blocks for one range?

A CIDR block must hold a power-of-two number of addresses and start at a multiple of its size. A range such as 192.168.1.10 to 192.168.1.20 is 11 addresses starting at an even but not a round number, so it takes four blocks: a /31, two /30s and a /32.

Is this the smallest possible list?

Yes. Taking the largest aligned block that fits at each step is known to give the minimum number of blocks for a contiguous range, which is also what Python’s ipaddress.summarize_address_range returns.

Can I convert a CIDR block back into a range?

Yes, with the Subnet Calculator on YappyKit: its network and broadcast addresses are the first and last addresses of the block.

Does it handle IPv6 ranges?

Not yet. This page is IPv4 only.

Related tools

Your files are processed on your device and are not uploaded. You can verify this in your browser’s developer tools under the Network tab.