IP Range to CIDR Converter |
Write a range as start - end (or "to"). IPv4 and IPv6; text after # is ignored. Results update as you type.
How to Convert an IP Range to CIDR
An IP range rarely fits one CIDR block: 10.0.0.5–10.0.0.20 needs 10.0.0.5/32, 10.0.0.6/31, 10.0.0.8/29, 10.0.0.16/30 and 10.0.0.20/32. This tool finds the smallest set of blocks, or merges a whole list of ranges into firewall-ready CIDRs, for IPv4 and IPv6.
Start at the first address and take the largest block that starts there and doesn't pass the end; repeat from the next address. A block of 2n addresses can only start on a multiple of 2n:
| Next address | Largest block that fits | Covers |
|---|---|---|
| 10.0.0.5 | /32 (5 is odd) | 10.0.0.5 |
| 10.0.0.6 | /31 (2 addresses) | 10.0.0.6–10.0.0.7 |
| 10.0.0.8 | /29 (8 addresses) | 10.0.0.8–10.0.0.15 |
| 10.0.0.16 | /30 (4 addresses; a /29 would pass .20) | 10.0.0.16–10.0.0.19 |
| 10.0.0.20 | /32 | 10.0.0.20 |
Merge Many Ranges Into CIDR Blocks
Paste ranges, CIDRs or single IPs; overlaps are merged and the result is the minimal list.
This is the job behind most allow-lists and block-lists: a provider's published ranges, a country list, or addresses collected from logs. Lines are sorted, overlapping and touching ranges are joined (10.0.0.0/25 and 10.0.0.128/25 become 10.0.0.0/24), and each merged range is split into the fewest aligned blocks. IPv4 and IPv6 can be mixed; lines that can't be read are listed with the reason instead of being guessed.
Use the Result in Firewall Rules
Copy the blocks as nginx, Apache, iptables or cloud security-group rules.
- nginx:
allowlines followed bydeny all;, for alocationorserverblock. - Apache 2.4: one
Require ipline with every block. - iptables:
ACCEPTrules, usingip6tablesfor IPv6 blocks. - nftables: named sets with
flags interval, to use in a rule such asip saddr @allowed_v4 accept. - AWS: a JSON permission list for
aws ec2 authorize-security-group-ingress --ip-permissions; it opens TCP 443 by default, so edit the port first.
Review generated rules before applying them: an allow-list that's wider than intended is a security problem.
CIDR to IP Range
A CIDR block's range runs from its network address to the last address: 192.168.1.0/24 → 192.168.1.0–192.168.1.255.
Enter a single block, such as 10.0.0.0/22, and the result shows its first and last address and size (10.0.0.0 to 10.0.3.255, 1,024 addresses). If the block was written with host bits set (192.168.1.77/24), the real network is shown. For the usable host range, broadcast address and mask, use the subnet calculator.
How This Tool Works
| Item | Detail |
|---|---|
| Where it runs | In your browser; nothing is sent to our server. |
| Input | Ranges (start - end, or "to"), CIDR blocks and single addresses, IPv4 and IPv6, up to 5,000 lines. Invalid lines are listed with the reason. |
| Method | Ranges are sorted and merged, then each is split greedily into the largest aligned blocks, which gives the minimal list. |
| Shareable link | ?q= followed by a range or block opens the page with it converted. |
| Stored | Nothing. |
| Last verified | 10 November 2026 |
Frequently Asked Questions
How do I convert an IP range to CIDR?
Why does one range need several CIDR blocks?
How do I convert CIDR to an IP range?
Can I merge many ranges at once?
Next steps