Free Online Developer Tool

IPv4 Subnet Mask Calculator

Calculate IPv4 subnet masks, network and broadcast addresses, usable host ranges, wildcard masks, and address counts from an IP address and CIDR prefix or subnet mask.

IPv4 Subnet Calculator CIDR to Subnet Mask Wildcard Mask Host Range Calculator
Enter an IPv4 address, such as 192.168.1.42.
Enter a prefix from /0 to /32 or a dotted-decimal mask.
Try an example:

What Is an IPv4 Subnet Mask Calculator?

An IPv4 subnet mask calculator determines the network address, broadcast address, subnet mask, wildcard mask, and host address range associated with an IPv4 address and a network prefix. It helps network administrators, IT students, and developers understand IP addressing and plan IPv4 networks.

You can enter a CIDR prefix, such as /24, or a dotted-decimal subnet mask, such as 255.255.255.0, to calculate the corresponding subnet information.

How to Use the Subnet Mask Calculator

  1. Enter an IPv4 address, such as 192.168.1.42.
  2. Enter a CIDR prefix, such as /24, or a subnet mask, such as 255.255.255.0.
  3. Select Calculate Subnet to display the results.
  4. Review the network address, broadcast address, host range, subnet mask, wildcard mask, and address counts.
  5. Use the Copy buttons to copy individual values or all results.

Example: Calculating a /24 Subnet

Suppose you enter the IPv4 address 192.168.1.42 and the prefix /24. The calculator identifies the network containing that address.

PropertyResult
Input IP address192.168.1.42
CIDR prefix/24
Subnet mask255.255.255.0
Network address192.168.1.0
Broadcast address192.168.1.255
First usable host192.168.1.1
Last usable host192.168.1.254
Total addresses256
Conventional usable hosts254

What Is a Subnet Mask?

A subnet mask is a 32-bit value that identifies which bits of an IPv4 address represent the network prefix and which bits represent the host portion. For example, 255.255.255.0 corresponds to /24, meaning that 24 bits identify the network prefix.

What Is CIDR Notation?

Classless Inter-Domain Routing (CIDR) represents an IP network using an address followed by a slash and a prefix length. For example, 192.168.1.0/24 identifies a network with 24 network bits and 8 host bits. CIDR supports flexible network sizing rather than relying on the historical Class A, B, and C addressing model.

Subnet Mask vs. Wildcard Mask

A wildcard mask is the bitwise inverse of a subnet mask. For example, the subnet mask 255.255.255.0 has the wildcard mask 0.0.0.255. Wildcard masks are commonly used in network access control lists and certain routing configurations.

How Are Usable Hosts Calculated?

For conventional IPv4 subnets with prefixes from /0 through /30, the number of usable host addresses is calculated by subtracting two from the total address count. The network address and broadcast address account for those two exclusions.

A /31 is a special case used for point-to-point links, where both addresses can be used as endpoints under RFC 3021. A /32 identifies one IPv4 address rather than a conventional multi-host subnet.

Common Uses of an IPv4 Subnet Calculator

  • Planning IP address allocations for local networks.
  • Checking network and broadcast addresses.
  • Determining the address range available within a subnet.
  • Converting between CIDR prefixes and dotted-decimal subnet masks.
  • Preparing network configuration and troubleshooting documentation.

Calculation and Compatibility Notes

This tool calculates IPv4 subnet information using JavaScript in your browser. It does not need an external calculation API. It validates IPv4 addresses and subnet masks before calculating the results.

The host counts follow the conventional IPv4 subnetting rules described above. Actual address assignment may also depend on the network environment, routing configuration, and operational policies. This tool does not test connectivity or verify whether an address is available on a live network.

Frequently Asked Questions

How do I calculate a subnet mask from an IP address?

An IP address alone does not determine a unique subnet mask. Enter the address and a CIDR prefix, such as /24, or a known subnet mask to calculate the network details.

What subnet mask corresponds to /24?

The subnet mask for /24 is 255.255.255.0. It contains 24 network bits and 8 host bits.

How many usable hosts are in a /24 subnet?

A conventional /24 IPv4 subnet contains 256 total addresses and 254 usable host addresses, excluding the network and broadcast addresses.

What is the difference between a subnet mask and a wildcard mask?

A wildcard mask is the bitwise inverse of a subnet mask. For example, 255.255.255.0 corresponds to the wildcard mask 0.0.0.255.

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

Yes. Enter a dotted-decimal subnet mask such as 255.255.255.0, or use CIDR notation such as /24. The calculator validates that the mask contains consecutive network bits followed by host bits.

What are the network and broadcast addresses?

The network address identifies the subnet, while the broadcast address is the last address in a conventional IPv4 subnet. For 192.168.1.0/24, they are 192.168.1.0 and 192.168.1.255, respectively.

How are /31 and /32 subnets different?

A /31 contains two addresses and can use both endpoints on a point-to-point link under RFC 3021. A /32 represents one IPv4 address and is commonly used to identify an individual host or route.

Does this calculator send my IP address to a server?

The subnet calculations in this implementation run in browser JavaScript and do not require an external calculation API. This describes the calculator code, not every network request or data-handling behavior of the website hosting it.