Subnet Mask Converter

Convert between CIDR prefix and dotted-decimal subnet mask.

Ad placeholder (leaderboard)
Enjoying the tools? Go Pro for £4.99 (one-time) and remove all ads — forever, on this device. Remove ads — £4.99

Switch in either direction between a CIDR prefix (/24) and a dotted-decimal subnet mask (255.255.255.0). The tool also derives the wildcard mask and the number of usable hosts, making it a quick reference when configuring routers, firewalls, and IP plans.

How it works

A subnet mask is just a run of leading 1 bits followed by 0 bits:

  • Prefix to mask: set the first p bits to 1. For /24 that is 11111111.11111111.11111111.00000000 = 255.255.255.0.
  • Mask to prefix: count the leading 1 bits — but only if they are contiguous. A mask like 255.0.255.0 is rejected because its 1 bits are not all on the left.
  • Wildcard mask = bitwise NOT of the subnet mask, e.g. 0.0.0.255 for a /24.
  • Usable hosts = 2^(32 − p) − 2, subtracting the network and broadcast addresses.

Example

Converting /26:

  • Mask = 255.255.255.192
  • Wildcard = 0.0.0.63
  • Usable hosts = 2^(32 − 26) − 2 = 2^6 − 2 = 62
PrefixSubnet maskWildcardUsable hosts
/24255.255.255.00.0.0.255254
/26255.255.255.1920.0.0.6362
/30255.255.255.2520.0.0.32

Everything runs in your browser; nothing is uploaded.

Ad placeholder (rectangle)