CIDR calculator
Convert an IPv4 CIDR block into its exact network range, or decompose any inclusive IPv4 range into the smallest exact set of CIDR blocks.
Inputs
Choose whether you are expanding one CIDR block or covering an inclusive IPv4 range.
Each octet is a required integer from 0 to 255. Dots are supplied by the calculator.
Required CIDR prefix length from 0 to 32; enter the number after the slash.
Required inclusive start of the IPv4 range.
Required inclusive end of the range; it must not be lower than the first address.
Live results
Enter a complete valid IPv4 value set to see results and enable the workbook export.
Network block
192.0.0.0/8
- IP
- 192.168.0.0
- Subnet mask width
- 8
- Subnet mask
- 255.0.0.0
- Prefix
- 192.0.0.0
- Wildcard bits
- 0.255.255.255
- First IP (network address)
- 192.0.0.0
- Last IP (broadcast address)
- 192.255.255.255
- Range
- 16,777,216
- Number of host addresses
- 16,777,214
Exact CIDR cover
5 CIDR blocks
- First IPv4 address
- 10.0.0.1
- Last IPv4 address
- 10.0.0.31
- Addresses covered
- 31
- CIDR block count
- 5
CIDR cover table
| CIDR | Starts at | Ends at | Addresses |
|---|
How to use this CIDR calculator
What this calculator does
This calculator works with 32-bit IPv4 addresses in two directions. In CIDR to IPv4 range mode, it combines an IPv4 address with a subnet mask width and identifies the aligned network prefix, dotted-decimal subnet mask, wildcard bits, first and last addresses, total address count, and the traditional host-address count. In IPv4 range to CIDR mode, it finds the smallest exact set of aligned CIDR blocks that covers every address from the first address through the last address. It is a deterministic addressing tool; it does not test reachability, confirm routing policy, assign addresses, or decide whether a special-purpose address is suitable for your network.
Use it when planning a subnet, checking whether an IPv4 address belongs to a particular prefix, translating a firewall or allow-list range into route-friendly CIDR blocks, or validating an addressing worksheet before configuring routers and services. The CIDR prefix notation described in RFC 4632 uses a slash followed by a decimal prefix length from 0 through 32.
How to calculate
- The calculator opens with a complete demonstration: 192.168.0.0/8. Its results and a validated example XLSX workbook are available immediately.
- Use I want to convert... to choose a direction. For a CIDR block, replace the four IPv4 address octets and Subnet mask width. For a range, replace all four octets under First IPv4 address and Last IPv4 address.
- Read the live result cards. In range mode, also review the CIDR cover table, whose CIDR, start, end, and address-count columns come from the same calculation used for the summary.
- Select Download Excel to create an XLSX workbook from the current valid controls. The workbook contains typed inputs, calculated results, and the current CIDR-block detail where applicable.
- Select Reset to clear the demonstration and all semantic address fields. Reset intentionally does not restore the startup example. The Excel button is disabled while the cleared or edited state is incomplete, then re-enables automatically after a complete valid state is entered.
Input guide
I want to convert... is required and accepts one of two modes: CIDR to IPv4 range or IPv4 range to CIDR. Changing it changes which address fields drive the canonical model; it does not reinterpret hidden stale values. A common mistake is expecting a range to collapse into one CIDR even when its start is not aligned to a power-of-two boundary.
IPv4 address contains the required First octet, Second octet, Third octet, and Fourth octet. Every octet is a base-10 integer from 0 through 255; for example, 192, 168, 0, and 0 form 192.168.0.0. Higher octets move the address to a different part of IPv4 space, while lower octets move it back. Enter digits only: decimal fractions, scientific notation, signs, commas, and pasted dotted addresses in a single octet are rejected rather than silently reinterpreted.
Subnet mask width is required in CIDR mode and is an integer from 0 through 32. The startup value is 8. A larger width fixes more network bits, producing a smaller block; a smaller width leaves more host bits, producing a larger block. Enter 24 for /24, not “/24”. The width is a bit count, not the dotted-decimal mask itself.
First IPv4 address and Last IPv4 address are required in range mode. Each is entered as four integer octets from 0 through 255; the example range is 10.0.0.1 through 10.0.0.31. The last address must be numerically greater than or equal to the first. Expanding either boundary can increase the number of addresses and may increase or decrease the number of CIDR rows depending on alignment.
Output guide
The header status pills are also live outputs: Mode echoes the active conversion direction, Input status reports whether the active fields form a complete valid state, and Excel status reports whether the current workbook has passed validation and is ready to download.
In CIDR mode, Network block is the aligned prefix plus slash width. IP echoes the entered IPv4 address; Subnet mask width echoes the bit width; Subnet mask shows its dotted-decimal form; Prefix and First IP (network address) show the lowest address in the block; and Wildcard bits are the bitwise inverse of the subnet mask. Last IP (broadcast address) is the highest address in the block. Range is the exact number of IPv4 addresses, equal to 2 raised to the number of host bits. Number of host addresses follows the traditional subnet convention of excluding network and broadcast endpoints when at least two host bits exist. For /31 point-to-point links, RFC 3021 permits both endpoints as host addresses; see the IETF guidance on 31-bit IPv4 prefixes.
In range mode, Exact CIDR cover reports how many blocks are required. First IPv4 address and Last IPv4 address reproduce the validated inclusive boundaries, Addresses covered is the exact inclusive count, and CIDR block count is the number of rows in the cover. The CIDR cover table lists each block under CIDR, Starts at, Ends at, and Addresses. A block count of one means the range is already one aligned power-of-two CIDR block; a higher count means several aligned blocks are needed.
Worked example
The startup example enters IP 192.168.0.0 with a subnet mask width of 8. A /8 mask has eight leading 1-bits, so its dotted mask is 255.0.0.0 and its wildcard is 0.255.255.255. Applying the mask keeps the first octet and clears the remaining 24 host bits, producing prefix 192.0.0.0. Filling those 24 host bits with 1s gives 192.255.255.255. The block contains 224 = 16,777,216 addresses, and the traditional host count is 16,777,214. Those values match the first rendered result cards and the startup workbook.
How the CIDR math works
IPv4 addresses are unsigned 32-bit values. A prefix length says how many of the most significant bits identify the network. The subnet mask contains that many leading 1s and then 0s. The network prefix is the address AND the mask. The broadcast endpoint is the prefix plus all host bits set to 1. That produces a block size of 2^(32 – prefix length).
Range decomposition works in the opposite direction. Starting from the first uncovered address, the algorithm takes the largest power-of-two block aligned at that address that does not extend past the requested last address. It then advances to the next uncovered address and repeats. This greedy procedure yields the minimal exact CIDR cover for a contiguous IPv4 interval.
Practical checks and common mistakes
Do not assume that the IP you type is already the network address. With 172.161.25.102/25, for example, the network prefix is 172.161.25.0, because the lower seven bits are host bits. Likewise, a range such as 10.0.0.1 – 10.0.0.31 cannot be represented by one exact CIDR block because the first address is not aligned to a 31-address power-of-two boundary; it decomposes into five blocks.
When writing examples, labs, or documentation, avoid borrowing arbitrary public addresses. The IETF reserves dedicated documentation ranges such as TEST-NET blocks; RFC 5737 documents those IPv4 example ranges. For production planning, also verify your organization's allocation, routing, firewall, cloud, and platform-specific constraints before deploying a calculated block.