Subnet Calculator
CIDR subnet calculator: enter an IP and prefix — get usable hosts, network, broadcast and range.
Subnetting splits networks into smaller pieces — essential for network engineers, homelab builders, and cloud architects. This calculator handles CIDR and dotted masks, validates input, and explains /31 and /32 edge cases.
Read the guide: Subnets and CIDR Without the Headache
Quick answers
What does a subnet calculator actually work out for you?
Give it any IP address and a prefix length, and it works out the block that address belongs to. You get the network address, the broadcast address, the usable host range, and how many hosts fit. You don't need to start from the network address itself. Enter a host address and it masks it down to its network first, then does the rest.
That saves you the fiddly bit most people get wrong. In a /26, blocks don't start at round numbers like 100 or 200. They start at 0, 64, 128, and 192 in the last octet. If you guess the start, you'll often guess wrong. Let the AND operation find it. Then read the rest of the numbers off that anchor, because every other value in the result hangs off the network address.
How many usable hosts are in a subnet, really?
Take the total addresses in the block and subtract two. A /26 has 64 addresses, so you get 62 usable hosts. A /24 has 256, so you get 254. The two you lose are the network address at the start, which names the block itself, and the broadcast address at the end. Neither one can go on a device.
Small blocks feel this pinch hardest. A /30 only has 4 addresses total, so just 2 are usable. That's why /30s mostly show up on point-to-point links between two routers, where two is exactly what you need. And the flip side matters too. If a plan gives you far more addresses than you'll ever use, that's not automatically wasteful. Address space inside a private network is free. A bit of headroom usually beats a renumbering job six months later.
Can you enter a normal host IP instead of the network address?
Yes, and you probably should if that's the address you actually have in front of you. The calculator ANDs your address with the mask, which wipes the host bits and drops it back to the start of its block. Enter 172.16.8.130/26 and you'll get results for the 172.16.8.128 network, not some block starting at 130.
This trips people up when they check the result and see a different starting number than the one they typed. Nothing's gone wrong. Blocks start where the mask says they start, not where your device happens to sit. If the network address in the result doesn't match what you typed, that's the tool doing its job. What you want to double-check is the prefix. Get the /26 wrong, type /24 by habit, and you'll get a perfectly consistent set of numbers for the wrong block.
How to use
- Type an IP with CIDR (192.168.1.0/24) — or an IP plus a mask in the second box.
- Click Calculate to see network, broadcast, usable range, masks and binary.
- Works for every prefix length from /0 to /32, including /31 point-to-point links.
About this tool
Using it as a CIDR subnet calculator for usable hosts: type an address with its prefix — 192.168.1.0/24, say — and read the Usable hosts row. The count is 2^(32 − prefix) − 2: a /24 has 256 total addresses and 254 usable hosts, a /26 has 62, and a /30 has 2. The two missing addresses are the network and broadcast addresses. /31 and /32 break the minus-two rule — a /31 point-to-point link has 2 usable hosts and a /32 has 1 — and the calculator handles both.
All math runs in your browser. No lookups, nothing uploaded.
How it works
The whole thing rests on two bitwise operations, and they're simpler than they look. To get the network address, you AND the IP address with the subnet mask, bit by bit. Where both bits are 1, you get a 1. Everywhere else, you get a 0. That strips off the host part and leaves you with the start of the block.
The broadcast address comes from the other operation. First you flip the mask to get the wildcard mask. That's just a bitwise NOT, so every 1 becomes a 0 and every 0 becomes a 1. Then you OR that wildcard with the network address. That sets all the host bits to 1, which lands you on the last address in the block.
That's also why you can type a host address and still get the right answer. Say you enter 172.16.8.130 with a /26 mask. You're not entering the network address, you're entering a machine inside it. The calculator masks it down anyway. The AND operation zeroes out the host bits, so 130 drops back to the network it belongs to. You don't have to work out the block start in your head first.
What this tool can’t do
This calculator only works with IPv4. It doesn't handle IPv6 at all, so if you're planning an IPv6 network you'll need a different tool. That's not a small gap either. IPv6 subnetting uses a much bigger address space and different habits, and none of the math here carries over.
It also only does the arithmetic for one subnet at a time. You give it an address and a prefix, it gives you that block's numbers back. It won't split a larger block into a VLSM plan for you, and it won't check whether two subnets you've designed overlap each other. Overlap checks are on you. Two tidy-looking plans can still collide if you don't lay them side by side.
It can't tell you if an address is actually free on a real network, either. There's no scanning here, no ping, no look at your DHCP leases or your routing table. The calculator doesn't know what's plugged in, what's reserved, or what someone assigned by hand last year and forgot to document. It just does the math for the block you describe.
One more practical limit. If you type a mask in dotted form, like 255.255.255.192, the 1 bits have to be contiguous. That means they run together with no gaps. A mask like 255.255.0.255 isn't a valid subnet mask, and the tool will reject it instead of guessing what you meant.
Here's a rule you can carry to any subnetting job. If the usable host count only just covers the devices you have today, you've already sized it too small. Networks almost always grow. A printer shows up, a camera gets added, someone brings in a test box. If you're within about 20 percent of the limit on day one, go one step larger while it's still cheap to change.
Worked examples
A host address in a /26 block: Say you enter 172.16.8.130/26 because that's the address on a machine you're documenting. The mask works out to 255.255.255.192, and the wildcard mask is 0.0.0.63. The block holds 64 addresses in total. Masking 130 down gives you a network address of 172.16.8.128, and setting the host bits gives you a broadcast address of 172.16.8.191. So the usable range runs from 172.16.8.129 to 172.16.8.190. That's 62 usable hosts, since the first and last addresses are spoken for. And since 172.16 sits in the private range, this is a class B private block. You're free to use it inside your own network without asking anyone.
Frequently asked questions
What is the difference between /24 and 255.255.255.0?
Nothing — they are two notations for the same mask. /24 means the first 24 bits are network bits, which written out is 255.255.255.0.
Why are 2 addresses "unusable"?
In a normal subnet the lowest address is the network identifier and the highest is the broadcast address — neither can be assigned to a host. /31 and /32 are special cases.
How do I calculate usable hosts from a CIDR prefix?
Usable hosts = 2^(32 − prefix) − 2. Subtract the network and broadcast addresses from the total: a /24 gives 2^8 − 2 = 254 usable hosts. Exceptions: /31 has 2 usable hosts (RFC 3021 point-to-point) and /32 has 1.
How many usable hosts are in a /24 subnet?
254. A /24 contains 256 addresses in total; the first (192.168.1.0 in the usual example) is the network address and the last (.255) is broadcast, leaving 192.168.1.1–192.168.1.254 assignable to devices.
Does it support IPv6?
Not yet — this version is IPv4 only.
What is a wildcard mask, and why does this tool show one?
It's the subnet mask flipped bit for bit. A mask of 255.255.255.192 becomes a wildcard of 0.0.0.63. You'll see wildcard masks most often in router access lists and routing protocols like OSPF, where config is written in wildcard form instead of mask form. This tool shows it so you can copy it straight into that kind of config without flipping the bits yourself. It's also how the broadcast address gets worked out, since network OR wildcard gives you broadcast.
I got a /32 result. Did I do something wrong?
Probably not. A /32 is a block with exactly one address in it. There's no network and broadcast pair eating up space, just that single host. You'll see /32s used for loopback addresses, for host routes that point at one specific machine, and sometimes handed out by providers. It's a legit result if you asked for a /32. If you didn't, check the prefix you typed. It's easy to fat-finger a number and end up with a block far smaller than you meant.
First time embedding? Read the step-by-step guide →
More free tools
UUID Generator
Generate random v4 UUIDs in bulk.
JSON Formatter & Validator
Format, minify and validate JSON in one click.
What Is My IP
See your public IP address instantly. No sign-up, nothing stored.
Regex Tester
Test, check and validate regular expressions with live highlighting.
JWT Decoder
Decode a JWT token without the secret — see its header and payload.
SHA-256 Hash Generator
Generate SHA-256 / SHA-512 hashes instantly.