Overview
Introduction
Firewall rules, allow lists, and routing tables are usually expressed as CIDR blocks, but the range you actually need to cover — say, a block of addresses assigned by a hosting provider — often comes to you as a plain start and end IP instead.
This tool converts that start/end range into the smallest set of CIDR blocks that covers it exactly, entirely in your browser.
What Is IP Range to CIDR Converter?
A converter that takes an inclusive IPv4 address range (a start IP and an end IP) and returns the minimal list of non-overlapping CIDR blocks that together cover exactly that range — no more, no fewer addresses.
It's the reverse operation of this site's CIDR Subnet Calculator, which expands a single CIDR block into its host range; this tool goes the other way, aggregating a range back into CIDR notation.
How IP Range to CIDR Converter Works
Both addresses are converted to their 32-bit unsigned integer form. Starting from the range's start address, the tool repeatedly finds the largest power-of-two-sized block that can legally start at the current address (determined by counting trailing zero bits in its integer form) without extending past the end of the remaining range, emits that block as CIDR notation, and advances to the next unaddressed integer.
This greedy, alignment-driven approach is the standard algorithm for range-to-CIDR aggregation: at every step it picks the single largest valid block, which is proven to minimize the total number of blocks produced.
When To Use IP Range to CIDR Converter
Use it when a provider, spreadsheet, or ticket hands you an IP range as a start and end address and you need CIDR notation for a firewall rule, security group, or allow list.
It's also useful for double-checking that a hand-written set of CIDR blocks actually corresponds to the intended contiguous range, with nothing missing or double-covered.
Often used alongside CIDR Subnet Calculator and IP to Long Converter.
Features
Advantages
- Always produces the minimal possible number of CIDR blocks for a given range, not just any valid covering set.
- Reuses this site's shared IPv4 parsing and integer-conversion logic, so validation behavior matches the other IP converters here.
- Reports the total address count alongside the block list, useful for a quick sanity check against the expected range size.
Limitations
- IPv4 only; IPv6 ranges aren't supported since the underlying integer math would need a 128-bit (BigInt) representation not currently wired up for IPv6 in this tool's shared helpers.
- Caps output at 512 CIDR blocks to keep results readable; a pathologically unaligned, very large range can need more blocks than that and should be split into smaller sub-ranges first.
Examples
Best Practices & Notes
Best Practices
- Check the reported total address count against what you expected before using the blocks in a firewall rule — a mismatch usually means the start or end IP was mistyped.
- When a range produces many small blocks, consider whether widening the range slightly (if the extra addresses are harmless to include) would let it collapse into fewer, larger blocks.
- Feed the resulting blocks into a tool like this site's Firewall Rules Generator or IP Allow List Generator rather than retyping them by hand.
Developer Notes
IPv4-to-integer and integer-to-IPv4 conversions are reused directly from ip-core.ts's ipToLong/longToIp rather than reimplemented, so validation (octet range, leading zeros) stays consistent with the other converters in this category. The block-splitting loop finds each block's maximum size via trailing-zero-bit counting on the current address (how large a power-of-two block can start there) capped by an integer loop against the remaining range length rather than Math.log2, avoiding floating-point rounding at large powers of two.
IP Range to CIDR Converter Use Cases
- Converting a hosting provider's assigned IP range (given as start/end addresses) into CIDR blocks for a security group or firewall rule
- Turning a spreadsheet of IP ranges into CIDR notation for a routing table or allow list
- Verifying that a manually assembled set of CIDR blocks exactly covers an intended contiguous range
Common Mistakes
- Entering the end IP before the start IP, which this tool rejects since the range would be empty or reversed.
- Expecting a single CIDR block for every range; only ranges whose start address and length are both power-of-two aligned collapse into one block.
Tips
- If you only need to double-check whether a specific address falls inside the range, it's simpler to compare it directly against the start and end IPs than to check it against every output block.