Subnet Calculator

Enter an IPv4 address and a prefix length — or a dotted subnet mask, whichever your equipment gave you — and get the network address, broadcast address, mask, wildcard mask, first and last usable host, and the host counts. It also handles the two cases that a surprising number of calculators get wrong. A /31 has two usable addresses under RFC 3021, not zero: the standard removes the network and broadcast reservation precisely so point-to-point links do not waste half a block, and /31 links are ordinary practice between routers. A /32 has one usable address, not minus one. Anything that blindly subtracts two from the total reports both incorrectly, and you will meet both on real infrastructure. Private and reserved ranges are matched by actual masking, so 172.32.0.1 is correctly public. Everything is computed in your browser.

Common prefixes

PrefixMaskTotalUsable
/24255.255.255.0256254
/25255.255.255.128128126
/26255.255.255.1926462
/28255.255.255.2401614
/30255.255.255.25242
/31255.255.255.25422 — RFC 3021
/32255.255.255.25511

When to use it

  1. Work out the usable host range before assigning addresses.
  2. Check what a /26 or /30 actually covers.
  3. Convert between a dotted mask and a prefix length.
  4. Get the wildcard mask for an access control list.
  5. Confirm whether an address is in a private range.

How to Use

  1. Enter an IPv4 address.
  2. Enter a prefix length such as 24, or a mask such as 255.255.255.0.
  3. Read off the network details and copy whichever you need.

Features

  1. Network, broadcast, mask and wildcard mask
  2. First and last usable host
  3. Total and usable host counts
  4. Correct RFC 3021 handling of /31
  5. Correct handling of /32
  6. Prefix length or dotted mask input
  7. Non-contiguous masks rejected with the reason
  8. Private and reserved range detection by masking
  9. 100% client-side, no lookups

FAQs

Why does this say a /31 has two usable hosts when other tools say zero?

Because RFC 3021 says two. The standard removes the network and broadcast reservation for /31 specifically, so point-to-point links do not waste half a block on overhead. Calculators that always subtract two from the total report zero, which would make a perfectly standard router-to-router link look unusable.

And a /32?

One usable address — it describes a single host, so there is no network or broadcast address to reserve. Subtracting two gives minus one, which is obviously wrong but is what a naive formula produces.

Can I enter a subnet mask instead of a prefix length?

Yes. Put either in the prefix field — 24 or 255.255.255.0 both work. A mask whose one-bits are not contiguous, such as 255.0.255.0, is rejected with that reason, since it is meaningless rather than merely unusual.

What is a wildcard mask for?

It is the inverse of the subnet mask, and Cisco access control lists use it instead. For a /24 the subnet mask is 255.255.255.0 and the wildcard is 0.0.0.255.

Why is the usable count two less than the total?

The first address in a normal subnet identifies the network itself and the last is the broadcast address, so neither can be assigned to a host. That rule is exactly what /31 and /32 suspend.

Is my data sent anywhere?

No. It is all arithmetic, done in your browser, with no lookups.

Technical Details

The address is converted to a 32-bit unsigned integer and masked, which is the whole of subnetting once the arithmetic is right — and the arithmetic has one trap worth naming. JavaScript's bitwise operators work on signed 32-bit integers, so shifting an address whose top bit is set produces a negative number, and anything from 128.0.0.0 upward comes out wrong unless every result is coerced back to unsigned. Two prefix lengths then break the ordinary rules, and this is where most calculators are simply incorrect. A /32 describes a single address: there is no network address and no broadcast address to reserve, so it holds one usable host. A /31 holds two addresses and RFC 3021 makes both of them usable, because the standard exists specifically to remove the network and broadcast reservation for point-to-point links, where dedicating half a four-address block to overhead was wasteful. Calculators that unconditionally subtract two from the total report zero usable hosts for a /31 and minus one for a /32, which is not merely cosmetic — a /31 is standard practice on router-to-router links, so the wrong answer appears on real infrastructure. Both cases are handled explicitly here and explained on screen. The prefix field accepts either a length or a dotted subnet mask, since people have whichever their equipment showed them, and a mask whose one-bits are not contiguous is rejected with that reason rather than silently producing nonsense. Private ranges are matched by masking rather than by string prefix, so 172.32.0.1 is correctly reported as public where a naive check on 172.16 through 172.31 written as text gets it wrong. Everything is computed in your browser.

Developer Tools

Developer Tools

  • IP & MAC Validator
  • URL Parser
  • URL Query Builder
  • Base Encoding Converter
  • Binary Text Converter
  • HTML Entities Encoder
  • Number Base Converter
  • JSON Tree Viewer