Subnet Calculator

Calculate subnet masks and ranges.

FreeNo accountOn your device

Runs in your browser. How to verify

Loading tool…

About this tool

Enter an IPv4 address with its prefix length to see the subnet mask, network address, broadcast address, first and last usable host and host count. Use it when planning subnets or checking a mask like 255.255.255.240.

How to use

1
Step 1
Enter IP/prefix, for example 192.168.1.0/24.
2
Step 2
Press Run.
3
Step 3
Read the mask and range.

How it works

The prefix length gives the mask: /24 is 255.255.255.0 and /28 is 255.255.255.240. Block size equals 2^(32 − prefix), and subnets start on multiples of that size. For /24, the network is.0, the broadcast is.255 and hosts run.1 to.254.

mask = (2^32 − 2^(32 − prefix)); block size = 2^(32 − prefix)

Worked example

A standard /24

Input
192.168.1.0/24
Output
{ "network": "192.168.1.0", "prefix": 24, "mask": "255.255.255.0", "broadcast": "192.168.1.255", "firstHost": "192.168.1.1", "lastHost": "192.168.1.254", "hostCount": 254 }
Walkthrough
The /24 block has 256 addresses; removing the network and broadcast leaves 254 usable.

Limitations

  • IPv4 only. It does not split a network into smaller subnets automatically.
  • Input must be IP/prefix; a bare mask like 255.255.255.0 is not accepted.
  • A /32 shows hostCount 2 even though it is a single address.

Questions

How do I calculate a subnet mask?
Enter the IP with its prefix length. The mask is shown in dotted form.
How many hosts in a /26?
62 usable hosts (64 addresses minus network and broadcast).
What is the broadcast address of 10.0.0.0/24?
10.0.0.255.
Can I enter the mask instead of a prefix?
No. Convert the mask to a prefix length first.

Features

  • Mask and range
  • Host count
  • Runs in your browser

Related resources

Guides and videos from around the web—opens on YouTube or the publisher’s site.

  • How base64 encoding works

    Andrew Schmelyun

    Mental model for Base64 encode/decode tools.

    Watch on YouTube
  • Learn JSON - Full Crash Course

    freeCodeCamp.org

    JSON is the payload format behind many developer tools here.

    Watch on YouTube
  • MDN Web Docs

    MDN

    Primary reference for web APIs these developer tools touch.

  • Introducing JSON

    json.org

    Canonical JSON grammar for formatters and validators.