CIDR Subnet & IP Calculator

Calculate IPv4 subnet masks, network addresses, broadcast addresses, usable IP host ranges, and binary representations for cloud networks (AWS VPC, GCP, Azure).

How to Use the CIDR Subnet Calculator

1

Input CIDR String

Enter any IPv4 CIDR notation (e.g. 10.0.0.0/24 or 172.16.0.0/16) or standalone IP address.

2

Calculate Metrics

Click Calculate CIDR Subnet to instantly compute network mask, broadcast address, and host ranges.

3

Copy & Export

Copy calculated JSON metrics or host ranges into your cloud deployment manifests (Terraform, AWS, CloudFormation).

Tool Options

Cloud Provider Subnet Scoping

Computes AWS VPC, Google Cloud, and Azure virtual network limits, reserving standard routing IP offsets correctly.

IP Address Classification

Detects public IPv4 spaces, loopback addresses, link-local addresses, and private RFC 1918 subnets instantly.

Infrastructure-as-Code Integration

Generates structured JSON subnet attributes ready for copy-pasting into Terraform, Pulumi, or CloudFormation specs.

Your Data Privacy

Web Tool
Privacy-First Architecture
Most of our web tools process your data entirely in-browser. Where server processing is technically required, payloads are evaluated statelessly in-memory and are never stored, saved, or logged.
REST API
Stateless In-Memory Processing
When you use our API endpoints, your requests are processed strictly in-memory without persistent database storage, disk logging, or data retention.
Want to learn more about how we safeguard your information and infrastructure?
Read our full Privacy Policy for detailed security standards, data retention principles, and compliance guarantees.

What does the CIDR Subnet & IP Calculator do?

The CIDR Subnet & IP Calculator computes network masks, broadcast addresses, first/last usable host IP ranges, and total host capacities from IPv4 Classless Inter-Domain Routing (CIDR) notation (e.g. 10.0.0.0/24 or 192.168.1.1/16). It provides full 32-bit binary breakdowns and identifies RFC 1918 private vs. public address spaces.

Core Concepts

Understanding CIDR prefix math and IPv4 address allocation:

  • Prefix Length & Mask Calculation: The prefix integer (e.g. /24) defines how many bits represent the network prefix, while remaining bits (32 - prefix) represent host identifiers.
  • Usable Host Space: Standard subnets reserve the first address for the Network ID and the last address for the Broadcast IP, yielding $2^{(32 - \text{prefix})} - 2$ assignable host addresses.
  • Address Classification: Automatically detects RFC 1918 private network ranges (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16), loopback networks (127.0.0.0/8), and traditional IPv4 classes (A, B, C, D, E).

How to use the tool?

  1. Enter CIDR Notation: Type or paste any IPv4 address with a prefix (e.g. 192.168.1.0/24) into the input box or click Load Sample.
  2. Calculate Metrics: Click Calculate CIDR Subnet to compute netmasks, host ranges, and binary representations.
  3. Copy & Export: Click Copy JSON or Download to export calculated subnet metrics for Terraform, CloudFormation, or network router configurations.

Related Developer Utilities

If you work with cloud networking, VPC infrastructure, and IP calculations, explore these complementary tools:

REST API Integration

Blueutils provides a free REST API endpoint (POST https://blueutils.com/api/network/cidr-calculator) to programmatically compute IPv4 network metrics, subnet masks, usable host IP ranges, total host counts, wildcard masks, and binary representations.

API Request Parameters

Name Type Description Example
rawText String CIDR notation string or IPv4 address string to calculate. "10.0.0.0/24"

API Request Payload Examples

cURL

curl -X POST https://blueutils.com/api/network/cidr-calculator \
  -H "Content-Type: application/json" \
  -d '{
    "rawText": "10.0.0.0/24"
  }'

Python

import requests

url = "https://blueutils.com/api/network/cidr-calculator"
payload = {"rawText": "172.16.0.0/16"}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())

Java

import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class Main {
    public static void main(String[] args) throws Exception {
        String jsonPayload = """
            {
                "rawText": "192.168.1.0/24"
            }
            """;

        HttpClient client = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create("https://blueutils.com/api/network/cidr-calculator"))
            .header("Content-Type", "application/json")
            .POST(HttpRequest.BodyPublishers.ofString(jsonPayload))
            .build();

        HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.body());
    }
}

API Response Parameters

Name Type Description Example
isValid Boolean Indicates whether CIDR calculation succeeded. true
cidr String Normalized CIDR notation string. "10.0.0.0/24"
netmask String Dotted-decimal subnet mask string. "255.255.255.0"
usableHostRange String Usable host IP address range. "10.0.0.1 - 10.0.0.254"
totalHosts Number Total count of addresses in the subnet. 256
usableHosts Number Total count of assignable host addresses. 254
ipClass String IPv4 address class designation. "Class A"
isPrivate Boolean Whether IP falls within RFC 1918 private space. true

API Response Payload Examples

Success Response (HTTP 200 OK)

{
  "isValid": true,
  "cidr": "10.0.0.0/24",
  "inputIp": "10.0.0.0",
  "prefix": 24,
  "netmask": "255.255.255.0",
  "wildcardMask": "0.0.0.255",
  "networkAddress": "10.0.0.0",
  "broadcastAddress": "10.0.0.255",
  "usableHostRange": "10.0.0.1 - 10.0.0.254",
  "firstUsableIp": "10.0.0.1",
  "lastUsableIp": "10.0.0.254",
  "totalHosts": 256,
  "usableHosts": 254,
  "ipClass": "Class A",
  "isPrivate": true,
  "ipType": "Private (RFC 1918)",
  "binaryIp": "00001010.00000000.00000000.00000000",
  "binaryNetmask": "11111111.11111111.11111111.00000000",
  "binaryNetwork": "00001010.00000000.00000000.00000000"
}

Validation Failure Response (HTTP 400 Bad Request)

{
  "isValid": false,
  "error": "Invalid Prefix Length: \"40\". Must be an integer between 0 and 32."
}

Rate Limit Exceeded Response (HTTP 429 Too Many Requests)

{
  "error": "API rate limit exceeded. Please wait or contact support@blueutils.com."
}

Why use an API to calculate CIDR subnets?

Integrating the CIDR Subnet Calculator API into cloud provisioning pipelines, Terraform modules, or infrastructure audit scripts provides key benefits:

  • Rapid Script Validation: Dynamically computes VPC subnet masks, broadcast limits, and host counts before applying cloud infrastructure changes.
  • Optimized Token Efficiency for AI Agents: LLMs frequently make bitwise math errors when calculating 32-bit subnet masks and usable host counts. Calling the API returns deterministic metrics without token hallucination.
  • Deterministic Accuracy Without Hallucinations: Ensures 100% bitwise accurate calculations conforming strictly to RFC 1918 and IANA IPv4 specifications.

Native Usage

How to calculate CIDR metrics locally in terminal environments or scripts:

Windows (CMD / PowerShell)

# Calculate CIDR metrics using Python ipaddress module in PowerShell
python -c "import ipaddress; n = ipaddress.ip_network('10.0.0.0/24'); print('Netmask:', n.netmask, 'Usable Hosts:', n.num_addresses - 2)"

Linux / Unix (Bash)

# Using ipcalc in Linux
ipcalc 10.0.0.0/24

Python

Using Python standard library ipaddress:

import ipaddress

network = ipaddress.ip_network("10.0.0.0/24")
print(f"Netmask: {network.netmask}")
print(f"Broadcast: {network.broadcast_address}")
print(f"Total Hosts: {network.num_addresses}")
print(f"Usable Range: {list(network.hosts())[0]} - {list(network.hosts())[-1]}")

Java

Using Java InetAddress and bitwise math:

import java.net.InetAddress;

public class CidrCalculatorExample {
    public static void main(String[] args) throws Exception {
        int prefix = 24;
        int mask = prefix == 0 ? 0 : 0xFFFFFFFF << (32 - prefix);
        byte[] bytes = new byte[] {
            (byte)(mask >>> 24), (byte)(mask >>> 16), (byte)(mask >>> 8), (byte)mask
        };
        InetAddress netmask = InetAddress.getByAddress(bytes);
        System.out.println("Subnet Mask: " + netmask.getHostAddress());
    }
}

Frequently Asked Questions (FAQ)

How do I calculate IPv4 CIDR subnets online?

Enter any IPv4 CIDR block (e.g. 10.0.0.0/24) or IP address into the input box and click Calculate CIDR Subnet.

What subnet metrics are calculated?

Our calculator computes the netmask (255.255.255.0), network ID, broadcast address, first usable IP, last usable IP, total usable host count, and IP classification (RFC 1918 private vs. public).

Is my IP network information stored or logged?

No. All CIDR math and subnet range calculations execute 100% client-side directly inside your browser. Your internal IP topologies and cloud VPC ranges are never saved remotely.

Rate Limits

UI Limits
100 uses per 15 minutes
Max payload size: 5 MB
API Limits
5 requests per 60 minutes
Max payload size: 256 KB
Need higher API rate limits, increased payload sizes, or custom developer solutions?
Contact our engineering team at support@blueutils.com for custom rate limit increases, higher quota allocations, or tailored enterprise integrations.