Why ranges and CIDR blocks need converting
Network records and tools describe address space in two ways. Some list a first and last address, such as a registry entry that gives a range, and others use CIDR notation, such as 192.0.2.0/24, which firewalls, routers, cloud security groups and access lists expect. Not every range is a single block, so a conversion is needed. This page takes an inclusive start and end address and returns the minimal list of CIDR blocks that together cover exactly those addresses, with nothing extra and nothing missing. Each block appears on its own line. The calculation is pure arithmetic on the numbers you enter. As the assumptions note says, it performs no DNS lookup and no scan of any network. It does not check whether the addresses are in use or who owns them.
How CIDR blocks work
CIDR, classless inter-domain routing, is described in RFC 4632. An address block is written as a base address and a prefix length, such as 192.0.2.0/24. The prefix length is the number of leading bits that are fixed, and the remaining bits can take any value. An IPv4 address has 32 bits, so a /24 leaves 8 free bits and covers 2 to the power of 8, which is 256 addresses. A /25 covers 128, a /30 covers 4, a /31 covers 2 and a /32 covers a single address. The key restriction is alignment. A block of size 2 to the power of k must begin at an address that is a multiple of that size. A /24 therefore must start at an address whose last octet is 0, and a /25 must start at 0 or 128. This is why many ranges cannot be written as one block.
The default example
The defaults are 192.0.2.0 to 192.0.2.255. The range holds 256 addresses, and the start address is a multiple of 256 with the last octet equal to 0. The largest aligned block that begins there and fits inside the range is a /24, so the result is the single block 192.0.2.0/24. The address block 192.0.2.0/24 is reserved by RFC 5737 for use in documentation, along with 198.51.100.0/24 and 203.0.113.0/24, so examples written with these addresses are safe to print because they are not assigned to real networks. A range of 198.51.100.0 to 198.51.100.127 gives 198.51.100.0/25, and 10.0.0.0 to 10.255.255.255 gives 10.0.0.0/8, which is the first of the private ranges in RFC 1918.
The greedy algorithm step by step
The calculation walks through the range from the start. At each step, it asks how large a block can begin at the current address. The block size is limited in two ways: the address must be a multiple of the block size, and the block must not extend past the end address. The calculator takes the largest size that satisfies both, writes down the block, moves to the first address after it and repeats. This greedy choice yields the minimal number of blocks, because no larger block could be aligned at the start, and shorter choices would only add blocks. When the range ends exactly on a block boundary, the process stops with no leftover. The sequence of block sizes typically rises as the start becomes more aligned and falls as the remaining space shrinks toward the end.
A range that needs several blocks
Take the range 192.0.2.10 to 192.0.2.20, which holds 11 addresses. The start, 10, is a multiple of 2 but not of 4, so the first block is a /31 covering 10 and 11. The next start is 12, a multiple of 4, and 12 to 15 fits, so the second block is 192.0.2.12/30. The next start is 16, a multiple of 16, but only five addresses remain, so the largest block that fits is a /30 covering 16 to 19. The last address, 20, is a /32 on its own. The result is 192.0.2.10/31, 192.0.2.12/30, 192.0.2.16/30 and 192.0.2.20/32. The sizes 2, 4, 4 and 1 add up to 11, which confirms the cover is exact. A shorter list of blocks that included addresses outside the range would be wrong, because it would allow traffic that the range does not.
A range that starts aligned but ends in the middle
The range 192.0.2.0 to 192.0.2.200 starts at a multiple of 256 but ends before the end of the /24. The first block cannot be a /24, because it would run past 200. A /25 covers 0 to 127 and fits. The next start is 128. A /26 covers 128 to 191 and fits, but a /25 starting at 128 would run to 255 and does not. The next start is 192. A /29 covers 192 to 199, and a /28 would run to 207, so the /29 is the largest that fits. The last address, 200, is a /32. The result is 192.0.2.0/25, 192.0.2.128/26, 192.0.2.192/29 and 192.0.2.200/32. The sizes are 128, 64, 8 and 1, which total 201. A range of 201 addresses has the binary form 11001001, and the number of ones in the pattern matches the four blocks.
Short lists versus the worst case
The number of blocks depends on how the range lines up with power-of-two boundaries. A perfectly aligned range of any power-of-two size gives one block. A range of just two addresses that straddles a boundary, such as 192.0.2.255 to 192.0.3.0, gives two /32 blocks, because the two addresses lie in different aligned groups. In the worst case, a range can need up to 62 blocks, since it can need up to 31 blocks on the rising side and 31 on the falling side. This matters for firewalls and cloud services that cap the number of rules in a list. If you control the range, choose one that aligns with block boundaries. If it comes from a registry or a vendor, you may have to accept several entries.
Where these ranges show up
Regional internet registries often publish allocations as ranges. A RIPE database object, for example, can list its inetnum as a first and last address. Cloud providers publish IP ranges for their services as CIDR lists, but a vendor document may give plain ranges. Security teams convert ranges to blocks to build allow lists and deny lists in firewalls, load balancers and web application rules. Network engineers use the same conversion when summarizing routes, since a route in a table is a prefix and a prefix is a block. The calculator gives the exact minimal cover for the range you enter. It does not aggregate across several ranges. For that, merge the ranges first and then convert, or convert each and let a tool combine adjacent blocks.
Usable hosts and special addresses
The block lists describe address space, not the number of hosts. In ordinary subnets the first address is the network address and the last is the broadcast address, so a /24 offers 254 usable host addresses. That rule has exceptions. A /31 is permitted on point-to-point links by RFC 3021 and has two usable addresses, and a /32 identifies a single host. Several ranges are special. The loopback block is 127.0.0.0/8, link-local addresses are in 169.254.0.0/16, and the private ranges are 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16. The calculator converts any valid range regardless of these categories and does not warn about them. Check the type of address space before you put a block in a rule that could expose or block something important.
Input rules and limits
Both fields take IPv4 addresses in dotted decimal form, and the end must not come before the start, or the calculator reports an error. A range with equal start and end gives a single /32. A range from 0.0.0.0 to 255.255.255.255 gives 0.0.0.0/0. The tool handles IPv4 only. IPv6 ranges are written in a different notation, with 128-bit addresses, and need a different tool. Because it works only with the numbers entered, the calculator cannot tell you whether the addresses are routable, allocated, in use or reachable. For production firewall changes, review the resulting blocks against your documentation, since a single mistyped octet can open or close a far larger range than you intended.
Masks, sizes and trailing zeros
Each prefix length has a block size and a subnet mask. A /24 holds 256 addresses with the mask 255.255.255.0. A /25 holds 128 with 255.255.255.128, a /26 holds 64 with 255.255.255.192, a /27 holds 32 with 255.255.255.224, a /28 holds 16 with 255.255.255.240, a /29 holds 8 with 255.255.255.248, a /30 holds 4 with 255.255.255.252, a /31 holds 2 with 255.255.255.254 and a /32 holds 1. Alignment can be read from the binary form of the start address. The number of trailing zero bits sets the largest block that can begin there. The address 192.0.2.128 ends in the binary value 10000000, which has seven trailing zeros, so a block as large as a /25 could begin there, if the range were long enough. The address 192.0.2.10 ends in 00001010, which has one trailing zero, so only a /31 can begin there.
Checking the result by counting addresses
A conversion is correct when the blocks tile the range exactly. First count the addresses in the range: end minus start plus one. For 192.0.2.0 to 192.0.2.200 that is 201. Then add the sizes of the blocks, where a /n block has 2 to the power of (32 minus n) addresses. The blocks 192.0.2.0/25, 192.0.2.128/26, 192.0.2.192/29 and 192.0.2.200/32 have 128, 64, 8 and 1, and the sum is 201. Next confirm that the blocks follow each other without gaps. A block with base B and size S ends at B plus S minus 1, so 192.0.2.0/25 ends at 192.0.2.127 and the next block begins at 128, and 192.0.2.192/29 ends at 199 where the final /32 begins at 200. If the counts differ, or if there is a gap or an overlap, an address was mistyped.