Subnet Mask Converter

Convert between CIDR prefix and dotted-decimal subnet mask.

Convert a CIDR prefix like /24 to a dotted-decimal subnet mask (255.255.255.0) and back, with wildcard mask and usable host count. Validates contiguous masks. Runs entirely in your browser. It runs free in your browser on Gera Tools, with nothing uploaded.

Last updated Source: Gera Tools

How does a prefix length map to a subnet mask?

The prefix is the number of leading 1 bits. /24 sets the first 24 bits to 1, giving 11111111.11111111.11111111.00000000 = 255.255.255.0.

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
/28255.255.255.2400.0.0.1514
/30255.255.255.2520.0.0.32
/32255.255.255.2550.0.0.00 (host route)

Where each mask appears in practice

/24 (255.255.255.0) is the most common office and home network size — 254 usable hosts, one broadcast, one network address. Most small organizations fit comfortably inside a /24.

/26 (255.255.255.192) splits a /24 into four equal subnets of 62 hosts each. Useful when a floor, a VLAN, or a department needs its own network segment but a full /24 would waste addresses.

/30 (255.255.255.252) gives exactly two usable host addresses — the classic point-to-point link prefix for connecting two routers or a router to a firewall. Almost no addresses are wasted on a link that only ever has two endpoints.

/32 (255.255.255.255) is a host route — one address, no network or broadcast. It appears in routing tables to force traffic for a specific IP through a particular path, and in loopback interface configurations.

Wildcard masks in access control lists. Cisco IOS access lists and OSPF area statements use wildcard masks instead of subnet masks. The wildcard is the inverse: 0.0.0.255 matches any host in a /24, while 0.0.0.3 matches exactly four addresses in a /30. This tool shows both so you can copy the right format for whichever context you are working in.

Everything runs in your browser; nothing is uploaded.