What it does
Firewalls, cloud allowlists and routers want prefixes, not arbitrary ranges. This tool converts a start–end range into the minimal set of CIDR blocks that covers exactly the same addresses, with no gaps and no extra addresses.
How it works
CIDR blocks are aligned to powers of two. A block of size 2^n must start at a multiple of 2^n, so not every range can be one prefix. The algorithm repeatedly takes the largest aligned block that fits inside the remaining range, then continues after it.
For example, 192.0.2.10–192.0.2.20 cannot be a single /28. It becomes several blocks: a /31 for the first pair, a /29 covering the next eight, a /30, and a /31 at the end. The union is exact.
IPv6 works the same way with 128-bit arithmetic. JavaScript numbers lose precision above 2^53, so a correct implementation uses BigInt. A tool that overflows will silently produce overlapping or missing blocks.
Order and adjacency matter. The output is sorted and should be merged when adjacent blocks can be combined into a larger aligned prefix. Fewer blocks mean smaller rule sets and less chance of a typo.
The conversion is not a security boundary by itself. A firewall may accept the prefixes but still need rules for direction, protocol and port. Convert the range correctly, then test with real traffic.
When to use it
- Turn a provider's published IP range into firewall rules.
- Add an office or VPN address span to a cloud allowlist.
- Summarise a long list of individual addresses into prefixes.
- Check that a proposed CIDR set exactly matches a required range.
Glossary
- CIDR
- Classless Inter-Domain Routing: an address plus a prefix length.
- Aggregation
- Combining adjacent blocks into the smallest equivalent set of prefixes.
- Alignment
- The requirement that a block of size 2^n starts at a multiple of 2^n.
- Supernet
- A larger prefix that contains a smaller one.
- BigInt
- Arbitrary-precision integer arithmetic, required for 128-bit IPv6 math.
Frequently asked questions
Why does one range produce several CIDRs?+
Because prefixes must be power-of-two aligned. An arbitrary start and end cannot always be expressed as one block without including addresses outside the range.
Can the output include addresses I did not ask for?+
A correct conversion does not. If a tool rounds outward, it is approximating. Check the first and last address of the result against your range.
Does it work for IPv6?+
Yes, using 128-bit BigInt math. IPv6 ranges often need many more blocks because the address space is sparse, but the algorithm is the same.
Why merge adjacent blocks?+
Fewer rules are easier to review and less likely to contain a typo. Merging is safe only when the combined block is aligned and fully covered.
Is the result safe to paste into a firewall?+
Review it first. Confirm the boundaries, the direction and the ports. The conversion is exact, but a correct range in the wrong rule is still an outage or a hole.
API & MCP
No API endpoint
This tool runs entirely in your browser. It is not available over the REST API or MCP.
Shareable result
https://100www.dev/tools/ip-range-to-cidr?v=192.0.2.0%20-%20192.0.2.255

100www engineering
EditorialReviewed by Steve · · Report an error
Tested from the 100www probe network; results vary by location and network.


