CIDR and IP subnet calculator
Calculate the range, mask and size of IPv4 and IPv6 networks, split them into subnets, and check what contains or overlaps what.
Code examples
Copy and paste these into your own project. Each one uses only the language's standard library, so there is nothing to install.
const cidr = '192.168.1.0/24'
const ip = '192.168.1.42'
const toNumber = (address) => address.split('.').reduce((total, octet) => total * 256 + Number(octet), 0)
const [network, prefix] = cidr.split('/')
const size = 2 ** (32 - Number(prefix))
const contains = Math.floor(toNumber(ip) / size) === Math.floor(toNumber(network) / size)
console.log(contains)What it does
Calculate the range, netmask, wildcard and size of IPv4 and IPv6 networks, split a network into subnets, and check what contains or overlaps what. All arithmetic is exact, so IPv6 works too.
How to use it
- Type or paste one network per line, such as
192.168.1.0/24or2001:db8::/32. A bare address counts as a single host, and an IPv4 netmask such as/255.255.255.0is accepted. - Pick a mode: Details shows each network’s range and size, Split cuts it into subnets of the prefix you choose, Contains checks an address against each network and Overlap finds networks that nest.
- Read the first network in detail below the output: mask, wildcard, usable hosts and what kind of address it is.
Examples
192.168.1.77/24 → 192.168.1.0/24 · 192.168.1.0–192.168.1.255 · 256
Splitting 10.0.0.0/24 into /26:
10.0.0.0/26
10.0.0.64/26
10.0.0.128/26
10.0.0.192/26
Good to know
- A /24 holds 256 addresses; each bit less doubles it.
- In IPv4 the first and last address are the network and broadcast address, so a /24 has 254 usable hosts. A /31 (RFC 3021) and a /32 use every address.
- A /64 is the usual size of one IPv6 network.
- At most 1024 subnets are listed when you split.
What is CIDR notation?
CIDR writes a network as an address and a prefix length, such as 192.168.1.0/24: the first 24 bits name the network and the rest are for hosts. A /24 holds 256 addresses, and each bit less doubles it. IPv6 works the same way with 128 bits, so a /64 is the usual size of one network.
Frequently asked questions
Why are two addresses not usable in an IPv4 subnet?
The first address names the network and the last is the broadcast address, so a /24 has 254 usable hosts. Point-to-point /31 networks (RFC 3021) and single-host /32s use every address.
What does split do?
It cuts a network into equal smaller ones: 10.0.0.0/24 split into /26 gives four subnets of 64 addresses each. At most 1024 subnets are listed.
Does this tool send my networks anywhere?
No. All calculations happen in your browser, with exact integer arithmetic so IPv6 works too. What you type is never sent to our servers.