Subnet / CIDR Calculator

Type an address and a prefix, such as 192.168.1.10/24, and every answer below updates as you type. Each one has its own Copy button.

How it works

An IPv4 address is a 32-bit number. The prefix length says how many of those bits, counted from the left, name the network. The rest name a device on that network. A /24 keeps 24 bits for the network and leaves 8 for devices, which is 256 addresses.

The calculator turns the prefix into a subnet mask (24 ones followed by 8 zeros, written 255.255.255.0), then keeps only the network bits of your address to get the network address, and sets all the device bits to one to get the broadcast address. Everything else follows from those two numbers.

You can type the mask instead of the prefix, as 192.168.1.10 255.255.255.0 or 192.168.1.10/255.255.255.0. The work is plain arithmetic on this page; nothing you type is sent anywhere.

How to use it

  1. 1 Type an IPv4 address followed by a prefix length (/24) or a subnet mask (255.255.255.0).
  2. 2 Read the network and broadcast addresses, the first and last usable host, and how many hosts fit.
  3. 3 Copy any single value with its Copy button, or copy everything at once with Copy all results.
  4. 4 Change the prefix to see how the same address falls into a bigger or smaller subnet.

Good to know

  • Usable hosts are the total minus two: the network address and the broadcast address cannot be given to a device.
  • A /31 is the exception. RFC 3021 lets a point-to-point link use both of its two addresses, and the calculator counts it that way.
  • The wildcard mask is the subnet mask with every bit flipped. Cisco access lists and OSPF ask for it instead of the mask.
  • An address with a leading zero, such as 192.168.010.1, is refused on purpose: some programs read 010 as octal 8 and others as decimal 10.

Browser support

  • Chrome 94 and later
  • Firefox 93 and later
  • Safari 16.4 and later
  • Edge 94 and later

These are the oldest versions with everything the tool uses. They are worked out from the tool itself, so they change when it does.

Version numbers checked on 2026-09-04.

Working out 172.16.5.4/20 by hand

Subnetting looks like a trick until you do one in binary, and then it is only bookkeeping. Take the address 172.16.5.4 with a prefix of /20. The /20 says that the first 20 bits of the address are the network and the last 12 are the device. Because 20 is not a multiple of 8, the boundary falls in the middle of the third number, which is exactly the case that trips people up.

Write the mask first. Twenty ones followed by twelve zeros, grouped in eights, is 11111111.11111111.11110000.00000000. The first two groups are 255. The third group, 11110000, is 128 + 64 + 32 + 16, which is 240. The last is 0. So the subnet mask is 255.255.240.0, and the wildcard mask, every bit flipped, is 0.0.15.255.

Now apply the mask to the address. The first two numbers, 172 and 16, pass through unchanged because the mask there is all ones, and the last number becomes 0 because the mask there is all zeros. Only the third number needs work: 5 in binary is 00000101, and keeping just the top four bits (the 1111 part of 11110000) leaves 00000000, which is 0. So the network address is 172.16.0.0.

For the broadcast address, set every device bit to one instead. In the third number the low four bits become 1111, giving 00001111, which is 15, and the last number becomes 255. The broadcast address is 172.16.15.255. The first usable host is one more than the network, 172.16.0.1, and the last is one less than the broadcast, 172.16.15.254. Twelve device bits give 2 to the 12th, 4,096 addresses, and taking away the network and broadcast leaves 4,094 hosts. Type 172.16.5.4/20 into the box above and every one of those numbers appears.

A shortcut falls out of this. The size of a subnet in the octet where the boundary falls is 256 minus the mask value there: 256 minus 240 is 16. So /20 networks in the third octet start at 0, 16, 32, 48 and so on, and 5 lands in the block from 0 to 15. That is how network engineers do this in their heads.

There are limits worth knowing. The usable-host count assumes an ordinary LAN. A /31 has no network or broadcast address under RFC 3021, so both of its addresses are usable, and a /32 is a single host; the calculator follows those rules. Cloud providers often reserve more: AWS keeps five addresses in every subnet, Azure keeps five, and Google Cloud keeps four, so the number of addresses you can actually assign there is lower than the textbook answer. The "old class" line is shown only because exam questions still ask about it. Classes stopped deciding network sizes when CIDR arrived in 1993.

Frequently asked questions

What does the /24 after an IP address mean?

It is the prefix length: the first 24 of the address’s 32 bits name the network, and the last 8 name a device on it. It is the short way of writing the subnet mask 255.255.255.0. A smaller number means a bigger network: a /16 holds 65,536 addresses, a /24 holds 256.

Why are there two fewer usable hosts than addresses?

The first address in a subnet is the network address, which names the subnet itself, and the last is the broadcast address, which reaches every device on it. Neither can be given to a single device. A /24 has 256 addresses and 254 usable hosts.

What is a wildcard mask?

The subnet mask turned inside out: every 1 becomes 0 and every 0 becomes 1. For a /24 it is 0.0.0.255. Cisco access control lists and OSPF network statements use it, where a 0 bit means "must match" and a 1 bit means "any value".

Does this work for IPv6?

No, this page is IPv4 only. IPv6 has its own calculator on YappyKit, which compresses and expands addresses and works out an IPv6 prefix.

Is the address I type sent anywhere?

No. The calculation is a few lines of JavaScript on this page. It works with the network unplugged once the page has loaded.

Related tools

Your files are processed on your device and are not uploaded. You can verify this in your browser’s developer tools under the Network tab.