IP Range to CIDR
Convert a start and end IP into the minimal set of CIDR blocks.
When you write firewall rules, routing tables, or access control lists, you often deal with arbitrary IP ranges like “192.168.1.10 through 192.168.1.200.” But most network devices and cloud security groups only accept CIDR notation (for example 192.168.1.0/24), not free-form ranges. This tool takes a start IP and an end IP and converts the range into the minimal set of CIDR blocks that cover it exactly.
It uses the standard IP range → CIDR algorithm, and all computation happens in your browser, so the IPs you enter are never sent anywhere. You can copy each CIDR block individually or the whole list at once, and you also get the total block count and total address count — ready to paste straight into a firewall, VPC, or routing configuration. To analyze a single CIDR in detail, use the CIDR calculator instead.
192.168.1.0/25192.168.1.128/31192.168.1.130/32
| Blocks | 3 |
|---|---|
| Total addresses | 131 |
How an IP range becomes CIDR
An arbitrary IP range often cannot be expressed as a single CIDR, because a CIDR block must always be a power-of-two size and must be aligned to that size. So the range has to be split into several aligned blocks. Starting from the first address, the algorithm repeats these steps:
- Find the largest block size the current start address can hold without breaking alignment (determined by its lowest set bit).
- Find the largest block size that does not exceed the number of remaining addresses.
- Pick the smaller of the two as the block, then advance the start address by that amount.
This covers the range exactly while keeping the number of blocks at a minimum. For example,192.168.1.0–192.168.1.130 splits into 192.168.1.0/25 (0–127),192.168.1.128/31 (128–129), and 192.168.1.130/32 (130).
Where you use it
- Firewalls / security groups: AWS Security Groups and GCP/Azure firewall rules accept CIDR only.
- Routing / static routes: Router and load balancer route entries need CIDR form.
- ACLs / WAF allowlists: Compressing an IP range into CIDR reduces the number of rules.
Before converting, the Private IP Checker helps you confirm whether the target range is private or reserved.
Things to note
This tool supports IPv4 only. The end IP must be greater than or equal to the start IP; if both are equal it becomes a single /32 host. Conversely, the full range 0.0.0.0–255.255.255.255 is expressed as a single 0.0.0.0/0.
Prefix length and block size cheat sheet
To sanity-check the split, it helps to know how many addresses each prefix (/n) covers. A block size is always 2^(32 − n), and the start address must be a multiple of that size (i.e. aligned).
| Prefix | Addresses | Subnet mask | Start must be (last octet) |
|---|---|---|---|
/32 | 1 | 255.255.255.255 | any value |
/31 | 2 | 255.255.255.254 | even (0, 2, 4 …) |
/30 | 4 | 255.255.255.252 | multiple of 4 (0, 4, 8 …) |
/29 | 8 | 255.255.255.248 | multiple of 8 (0, 8, 16 …) |
/28 | 16 | 255.255.255.240 | multiple of 16 (0, 16, 32 …) |
/24 | 256 | 255.255.255.0 | last octet 0 |
/16 | 65,536 | 255.255.0.0 | third & fourth octets 0 |
Worked example: 10.0.0.5 – 10.0.0.20
This shows how an unaligned start address forces small blocks first. The start 10.0.0.5 is odd, so it can only hold a /32 (not even, so no /31). Step by step:
| Step | Current start | Max by alignment | Emitted CIDR |
|---|---|---|---|
| 1 | 10.0.0.5 | 1 (odd) | 10.0.0.5/32 |
| 2 | 10.0.0.6 | 2 (6 is even) | 10.0.0.6/31 |
| 3 | 10.0.0.8 | 8 (multiple of 8); 13 left, so pick 8 | 10.0.0.8/29 |
| 4 | 10.0.0.16 | 5 left (16–20), so pick 4 | 10.0.0.16/30 |
| 5 | 10.0.0.20 | 1 left | 10.0.0.20/32 |
Sixteen addresses (5–20) split into five CIDRs. Had the range been the cleanly aligned10.0.0.0 – 10.0.0.15, it would have collapsed to a single 10.0.0.0/28. In other words, for the same address count, the block count depends heavily on alignment.
Common pitfall
- Guessing the prefix from the count: it is tempting to think “16 addresses, so one
/28,” but unless the start is a multiple of 16 it can never be a single/28. Alignment matters before count. - Entering the end IP as exclusive: the end IP here is inclusive. To cover up through
10.0.0.20, enter10.0.0.20. Entering10.0.0.21includes one extra address and changes the blocks. - Worrying about network/broadcast addresses: a CIDR block covers the entire address range including the network and broadcast addresses, so no address inside your range is ever left out.
Frequently asked questions
Why is one range split into several CIDRs?
Is the result really the minimal number of blocks?
Does it convert IPv6 too?
Are the IPs I enter sent to a server?
Related guides
- Subnetting & CIDR Basics: Splitting a /24What CIDR notation and subnet masks mean, with a worked example of splitting a /24.