IP range and CIDR converter

IP range and CIDR converter

Convert between start–end ranges and CIDR, merge lists and subtract ranges

Computed in your browser

One entry per line — CIDR, start–end range or a single address. Switch the output format to move between CIDR and ranges.

Each line can be a CIDR, a start–end range or a single address. IPv4 and IPv6 are both accepted and are never merged together.

Example

Input

10.0.0.0/24
10.0.1.0/24
10.0.3.7-10.0.3.9

Example result

10.0.0.0/23
10.0.3.7/32
10.0.3.8/31

The first two ranges touch and collapse into 10.0.0.0/23; the third is not power-of-two aligned, so it takes two blocks.

Technical details & limits

Every address is converted to an integer and all arithmetic uses JavaScript BigInt, so IPv6’s 128 bits keep full precision. Merging sorts by start address and sweeps once, treating a range as adjacent when its start is at most one past the current end. Converting a range to CIDRs walks from the start and takes the largest aligned block that does not overrun the end, which yields the smallest possible set. Subtraction is an interval difference, and the remainder is printed in the chosen format.

About this tool

Turn a pile of IP ranges into a list you can actually use: write each line as a CIDR, a start–end range or a single address, and the tool sorts them, merges whatever overlaps or touches, and prints the result as CIDRs, as ranges, or with per-range details. It can also subtract one set from another, which is how allowlists and exclusion lists get built. IPv4 and IPv6 are both supported and are merged separately. Everything runs in your browser, so the list never leaves your machine.

Use cases

  • Collapse a scattered list of ranges into the fewest CIDRs for a firewall rule or ACL.
  • Cut a few ranges out of a larger block to produce an exclusion list or allowlist.
  • Check the first and last address, netmask and usable host count of a CIDR.

How to use

  1. Enter the ranges one per line; CIDRs, start–end ranges and single addresses can be mixed.
  2. Choose the operation: merge only, or also subtract a second set of ranges.
  3. Choose the output: CIDRs, start–end ranges, or details with netmask and host counts.
  4. Copy the result, or save it as a text file with the button below it.

Notes

Merging happens within one address family only; IPv4 and IPv6 are handled separately. Ranges that touch are combined (10.0.0.0/24 and 10.0.1.0/24 become 10.0.0.0/23), so switch to range output if you need the original boundaries kept. Netmask, network and broadcast addresses appear only for IPv4 blocks that are exactly one CIDR; /31 and /32 have no separate network or broadcast address and none is shown. This tool only does address arithmetic — it looks nothing up and probes nothing.

FAQ

How do I calculate the number of addresses in an IPv4 CIDR network?
An IPv4 CIDR network contains 2 raised to the number of host bits, with host bits equal to 32 minus the prefix length. For example, a /24 contains 256 addresses. This is the complete interval size, not automatically the number of usable hosts. Network purpose and prefix-specific conventions affect host availability, so do not apply a universal subtraction rule without checking the intended network usage.
Does IPv6 range calculation preserve all 128 address bits?
This tool uses BigInt integers for IPv6 arithmetic, preserving all 128 address bits without floating-point rounding. A /64, for example, contains 2 raised to the power of 64 addresses. Merging and subtraction use integer boundaries as well. The result describes address intervals only; it does not determine which addresses have been assigned, whether the network is routed, or whether any device in the resulting interval is reachable.
Why can converting an IP interval to CIDR require several networks?
An arbitrary IP interval fits one CIDR block only when its size and starting address meet the required alignment. Even a range of 4 addresses needs the correct starting boundary to form 1 block. The tool repeatedly selects the largest aligned block that stays within the endpoint. This produces the minimum number of blocks covering the interval without including extra addresses outside the supplied start and end values.

Related tools

IP range and CIDR converter · Convert between start–end ranges and CIDR, merge lists and subtract ranges
IP range and CIDR converter — Tool illustration · dayeku.com