Subnet Mask Calculator
Calculate IPv4 subnet details: network, broadcast, host range, CIDR, mask, wildcard, binary mask, and suggest CIDR for desired hosts.
Updated
What is the Subnet Mask Calculator?
Subnet Mask Calculator
This tool calculates IPv4 network details from an IP address plus a mask or CIDR notation. It returns the normalized IP/CIDR, dotted decimal mask, binary mask, wildcard mask, network and broadcast addresses, usable host range, and counts for total and usable hosts. It also suggests the smallest CIDR prefix that fits a given number of usable hosts to help with subnet planning.
Key capabilities:
- Accepts inputs like 192.168.1.10, 192.168.1.10/24, 10.0.0.5 255.255.255.0, or /24.
- Validates IPv4 addresses and contiguous netmasks and surfaces clear error messages.
- Handles edge cases (/31 and /32) explicitly and shows how usable hosts are reported.
- Provides quick actions and copy buttons for easy export and planning.
Use this tool when designing networks, preparing subnets for hosts, or verifying existing IP allocations.
How it works
- Input parsing
- The tool accepts either a single value with CIDR (for example 192.168.1.10/24) or two fields: an IPv4 address and a mask (dotted mask like 255.255.255.0, numeric 24, or /24 form). The parser first normalizes these inputs and validates the IPv4 dotted-quad format.
- Mask validation and conversion
- If a dotted mask is provided it is converted to a 32-bit mask number and validated for contiguous '1' bits (non-contiguous masks are rejected). Numeric CIDR prefixes are validated to be integers between 0 and 32. The tool converts between CIDR, dotted decimal mask, wildcard mask, and a grouped binary representation for clarity.
- Core network calculations
- The core math uses bitwise operations on 32-bit unsigned representations of IPv4 addresses:
- Network address = IP & mask
- Broadcast address = network | (~mask)
- Total hosts = 2^(32 - prefix)
- Usable hosts = total - 2 for common subnets (with explicit handling for /31 and /32)
- First and last usable host addresses are computed with attention to edge cases so the result matches common network planning conventions.
- Reverse subnetting (CIDR suggestion)
- When you enter a desired usable-host count the tool searches for the smallest prefix where usableHosts >= desiredHosts. The suggested prefix is returned and applied to the mask field for quick planning.
- UX and output
- All logic is pure and client-side for instant feedback. The UI shows structured results (Network/CIDR, Broadcast, Mask, Wildcard, Binary mask, host range, counts) and provides copy buttons, a CodeEditor for binary mask, and quick action presets for common masks. Validation errors are shown as clear, human-readable alerts.
Notes on special cases
- /31: treated as a two-address point-to-point block; the tool shows both addresses and explains their behavior.
- /32: single IP host route; total and usable hosts are shown accordingly.
Examples
Compute standard /24 network from IP
Enter an IPv4 address and /24 to get network details for a typical Class C subnet.
Suggest smallest prefix for 50 usable hosts
Provide desired usable hosts to get the minimal CIDR prefix that fits the requirement.
Handle IP plus dotted mask
Accepts IP and dotted netmask and returns normalized CIDR and network info.
Frequently asked questions
What input formats are accepted?
What input formats are accepted?
You can enter a single combined value like 192.168.1.10/24, or provide the IPv4 address and mask separately using a dotted mask (255.255.255.0), numeric prefix (24), or /24. The tool normalizes inputs and validates them before computing results.
How does the tool compute the network and broadcast addresses?
How does the tool compute the network and broadcast addresses?
The tool converts the IPv4 address and mask to 32-bit integers and uses bitwise operations: network = IP & mask, broadcast = network | (~mask). These integer results are converted back to dotted-quad strings for display.
What does the tool do for /31 and /32 networks?
What does the tool do for /31 and /32 networks?
It explicitly handles these edge cases: /31 is shown as a two-address point-to-point block (both addresses are displayed), and /32 is a single-host route. Usable host reporting is explicit so you can decide how to interpret them in your network.
Why might a mask be rejected as invalid?
Why might a mask be rejected as invalid?
The tool enforces contiguous ones in the netmask (e.g., 255.255.0.255 is invalid). Non-contiguous masks are historically incorrect for standard IPv4 subnetting and are rejected with a clear error message.
How does the "Suggest prefix for N hosts" feature work?
How does the "Suggest prefix for N hosts" feature work?
Provide the desired number of usable hosts; the tool finds the smallest CIDR prefix whose usable host count meets or exceeds your requirement, then applies that prefix to the mask field to help with quick planning.
Are the calculations done locally or on a server?
Are the calculations done locally or on a server?
All calculations run locally in your browser with pure client-side logic; no network requests or external services are used. This keeps the tool fast and private.
Can this tool plan multiple subnets (VLSM) or export CSV?
Can this tool plan multiple subnets (VLSM) or export CSV?
Not in the first version. The tool focuses on single-subnet calculations and CIDR suggestion. Export and VLSM splitting can be added as enhancements; request these features and they can be included in the next iteration.
Is IPv6 supported?
Is IPv6 supported?
This tool currently supports IPv4 only. IPv6 support requires a different calculation model and UI; it can be added in a future update on request.
Related tools
More utilities you might find handy.
URL Parser
Break any URL into scheme, host, path, query parameters, fragment and more
.env File Generator
Quickly generate clean, properly-quoted .env files from key-value pairs — no more quoting errors or broken deployments.
.htaccess Redirect Builder
Generate error-free Apache .htaccess code for 301 redirects, HTTPS enforcement, and canonical URL routing.