ShowIP.net Public IP and request tools
Menu

Network tool

Range to CIDR

Convert a start and end IPv4 or IPv6 address into the smallest set of covering CIDR blocks.

Reference

Output fields

Start and end address
The inclusive range that must be covered by the returned CIDR blocks.
IP version
The start and end values must both be IPv4 or both be IPv6.
CIDR blocks
The smallest set of blocks that exactly covers the submitted range.
Block count
Several blocks may be needed when a range is not aligned to one larger CIDR boundary.

Advertisement

Overview

What this tool does

Range to CIDR converts a start and end IP address into the smallest set of CIDR blocks that covers that exact range.

It is useful when a vendor gives you raw IP ranges but your firewall, router, cloud rule, or API expects CIDR notation. For smaller network slices, use the subnet splitter.

Examples

Example ranges

Single CIDR block

8.8.8.0 - 8.8.8.255 Converts cleanly to one /24 block. Convert /24 range

Uneven range

8.8.8.1 - 8.8.8.3 Requires more than one CIDR block because the range does not start on a larger block boundary. Convert uneven range

Results

How to read results

The CIDR block list is an exact cover of the start and end address range. If several blocks are returned, use all of them together; dropping one block changes the covered range.

Boundaries

Limits

Start and end addresses must use the same IP version, and the start address must be lower than or equal to the end address. The result optimizes for the fewest CIDR blocks, not for provider ownership or routing policy.

IP and CIDR libraries

Build the same kind of checks into your code using these documented libraries.

Python: ipaddress

Standard-library IPv4 and IPv6 parsing, networks and membership checks.

Go: net/netip

Standard-library address and prefix types with Contains and Overlaps methods.

ShowIP endpoint documentation

Next steps

Advertisement