IP Range to CIDR Converter

Turn an IP range into CIDR blocks, or merge a list of blocks.

Addresses a range, CIDR blocks, or single IPs

One per line, or separated by commas.
local_cafe  Free and ad-free. Saved you time? Help keep it running. Buy me a coffee About the project

Exact list or one block: what each costs

A range rarely lines up with one CIDR block, so there are two answers. The exact list covers precisely your addresses. A single block is shorter to write but also takes in whatever sits in between. Use the exact list for firewall rules and allowlists; a single block only where the extras are acceptable, such as a route summary.

192.168.1.10-192.168.1.20

OptionCIDRAddressesNot in your input
Exact list 192.168.1.10/31, 192.168.1.12/30, 192.168.1.16/30, 192.168.1.20/32 11 0
Single block 192.168.1.0/27 32 21 (65.6%)

10.0.0.0/24, 10.0.1.0/24, 10.0.2.0/24

OptionCIDRAddressesNot in your input
Exact list 10.0.0.0/23, 10.0.2.0/24 768 0
Single block 10.0.0.0/22 1,024 256 (25%)

Frequently asked questions

How do you convert an IP range to CIDR?

Starting at the first address, take the largest CIDR block that is aligned at that address and still fits inside the range, then repeat from the address after it. Most ranges need several blocks; a range only becomes a single block when its start is aligned and its size is a power of two.

Why does one IP range turn into several CIDR blocks?

A CIDR block must start on a boundary that is a multiple of its size. A range such as 192.168.1.10 to 192.168.1.20 does not line up with one boundary, so it takes a /31, two /30s and a /32 to cover it exactly.

What is the difference between an exact list and a covering block?

The exact list covers precisely the addresses you gave and nothing else. A covering block is the single smallest CIDR block that contains them all, which is shorter to write but usually includes addresses you did not ask for. Use the exact list for firewall and allowlist rules.

How do I summarize a list of CIDR blocks?

Paste the blocks, comma separated or one per line. Adjacent and overlapping blocks are merged and the result is the smallest exact set of blocks. If a single block would cover them, it is shown with the extra addresses it would add.

Use it from code

curl "https://networkcalc.com/api/range/192.168.1.10-192.168.1.20"
curl "https://networkcalc.com/api/range/10.0.0.0/24,10.0.1.0/24,10.0.2.0/24"

See the IP Range to CIDR API docs. Planning an address space instead? The VLSM calculator divides a network for several groups at once.

More Tools