Subnet Calculator

Enter an IPv4 address with a prefix or a subnet mask to get network address, broadcast, usable host range and a binary view.

Subnet calculation

Both IP/prefix and IP mask forms work. IPv4 only. Without a prefix the input is treated as a /32.

Prefix ↔ mask converter
Conversion
Type on one side and the other converts live.

The prefix counts the leading ones in the mask. /26 matches 255.255.255.192, and the mapping is one to one.

How to use

  1. Type an IPv4 address and its block. Use the slash form like 192.168.1.130/26, or the address plus mask form like 192.168.1.130 255.255.255.192.
  2. Results refresh as you type: network address, broadcast address, usable host range, mask, wildcard mask and address counts.
  3. Read the binary view: network bits sit left of the bar and host bits sit right of it, which shows exactly where the boundary lands.
  4. Use the prefix and mask converter below when you only need a conversion. Type on either side and the other side follows.
  5. The copy buttons hand over the binary view or the whole result text.

FAQ

What is special about /31 and /32?
A /31 is a point-to-point link under RFC 3021. It has no network or broadcast address, and both addresses can be configured on the two ends. A /32 describes a single host route, so the usable host is the address itself, which is common for loopback interfaces and precise host routes.
Why are usable hosts two fewer than total addresses?
The address with all host bits at zero stands for the block itself, the network address. The address with all host bits at one reaches every device in the block, the broadcast address. Neither can be assigned to a normal host. /31 and /32 are the exceptions, and the tool follows their own rules and explains them.
What happens with a mask like 255.0.255.0?
A mask with mixed ones and zeros breaks the CIDR rule of a run of ones followed by zeros, so routing equipment cannot use it. The tool rejects the input and says why. Replace it with an equivalent contiguous mask.
Does it support IPv6?
No. This tool handles IPv4 only. Input containing a colon is detected as IPv6 and reported. IPv6 has a different address structure and prefix notation, so it needs its own calculation.

How to use

  1. Enter the address

    Type an IPv4 address followed by a slash prefix, for example 192.168.1.130/26. A space plus a full mask works as well, and the results update live.

  2. Read the results

    The panel lists network address, broadcast address, usable host range, mask and wildcard mask. Every value comes from 32-bit unsigned integer math.

  3. Check the labels

    The result names the A to E class and any special range. Addresses starting with 10, 172.16 or 192.168 are flagged as RFC1918 private, and loopback or link-local ranges are marked too.

  4. Convert both ways

    The converter below works on its own. Enter /26 to get 255.255.255.192, or type a mask to get the matching prefix length back.

About this tool

A subnet calculator takes one IPv4 address and shows the block it belongs to. An IPv4 address has 32 bits: the leading bits identify the network, and the remaining bits identify a host inside that network. The number after the slash counts the network bits, so /26 leaves 26 network bits and 6 host bits. The subnet mask marks the same boundary with a run of ones, and /26 corresponds to 255.255.255.192. AND the address with the mask and you get the network address, which stands for the whole block. Setting every host bit to one produces the broadcast address, which reaches every device in the block.

Both ends of a block hold special roles. The network address has all host bits at zero. The broadcast address has all host bits at one. Neither can be assigned to a normal host, so a regular block offers its total count minus two usable addresses. /31 is the exception: RFC 3021 allows both addresses on a point-to-point link, so the usable count is two. A /32 describes a single host route, and its usable count is one. The tool explains these edge cases on the page and warns you when the input address happens to be a network or broadcast address. Everything runs locally in your browser, and no address you type leaves your device.

How it works

The calculator rests on 32-bit unsigned integer math. Dotted decimal first becomes one 32-bit unsigned integer. The mask is built by shifting ones into the top of a 32-bit word. A /0 mask stays all zeros because shift counts wrap at 32. The network address is the bitwise AND of the address and the mask. The wildcard mask is the bitwise NOT of the mask, and the broadcast address is the network address OR the wildcard. JavaScript bitwise operators work on signed 32-bit values, so NOT or a left shift can produce a negative number. Every step ends with an unsigned right shift that keeps results between 0 and 4294967295. The converter shares the same functions as the main calculation, so both entries agree.

The A to E classes come from the old classful addressing scheme. CIDR took over routing aggregation long ago, yet the classes still work as a quick identity check. First octets 1 to 126 belong to class A, 128 to 191 to class B, and 192 to 223 to class C. Ranges 224 to 239 are class D multicast, and 240 and above belong to the reserved class E. RFC1918 set aside three private blocks: 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16. These never appear in public routing tables. The loopback block 127.0.0.0/8 points back to the local machine. The link-local block 169.254.0.0/16 serves automatic configuration when DHCP fails. The tool reports the class and any special block together, which makes the identity of an address easy to read.

When to use it

  1. Split an office network

    When one /24 has to be divided into per-department subnets, try each candidate prefix here first. Compare the network address and usable host count of every option, and confirm the gateway and server addresses land inside the usable range. Then write the winning plan into the switch and DHCP configuration.

  2. Configure a router

    Home and business router panels usually ask for an interface address plus a mask. Enter both in mask form, then read back the network and broadcast addresses before saving. This catches setups where the LAN address was accidentally the network address or the two sides use different mask lengths.

  3. Diagnose connectivity

    When two devices cannot reach each other, calculate the block of each address and compare the network addresses. A mismatch means the devices sit in different subnets, and a wrong mask length is one of the most common causes. The binary view shows the boundary in one glance.

Tips & tricks

  • Plan subnets from the host count backwards. Six host bits serve 62 hosts, which is exactly a /26.
  • Reserve the first usable address for the gateway. The hosts you can actually assign are one fewer than the tool reports.
  • When troubleshooting, read the private label first. A private address inside a public route usually points to a NAT or routing mistake.

Things to watch

  • Non-contiguous mask

    A mask like 255.0.255.0 mixes ones and zeros and breaks the CIDR rule. Routing equipment cannot use it, because the block it describes has no clean network boundary. The tool rejects the input and explains the reason. Replace it with an equivalent contiguous mask such as 255.255.0.0.

  • Prefix out of range

    A prefix must be an integer from 0 to 32. Values like /33 or a negative number are rejected. Use /0 for the whole address space and /32 for a single host instead of larger numbers. Typing 33 where 32 was meant is a common slip, and the error message names the allowed range.

  • Total vs usable hosts

    The total count includes the network and broadcast addresses, so usable hosts are two fewer. A /24 holds 256 addresses in total and 254 usable ones. Plan assignments from the usable count and never hand out the two end addresses.

Related Tools