CIDR to Subnet Mask Calculator
Enter the CIDR prefix length to get its subnet mask.
Result
How it is calculated
A CIDR prefix /n means the first n bits of a 32-bit IPv4 address are the network part. The mask is therefore n ones followed by 32 − n zeros, written as four decimal bytes. The wildcard mask is the bitwise inverse of that mask. The number of usable hosts is 232 − n − 2: the all-zeros host address is the network address and the all-ones one is the broadcast address, so both are excluded. The prefix must be a whole number from 0 to 32; a decimal such as 24.9 is truncated to 24, and a value outside 0–32 gives no result. For /31 and /32 the formula gives 0, so the tool shows 0 usable hosts, even though /31 is used on some point-to-point links and /32 identifies a single host.
Worked example
Take a /26 prefix. The first 26 bits are ones, so the first three bytes are 255 each, and the last byte holds 2 ones and 6 zeros: 11000000 = 128 + 64 = 192. Mask: 255.255.255.192. The wildcard is the inverse, 0.0.0.63. Host bits: 32 − 26 = 6, so 26 = 64 addresses, minus network and broadcast leaves 62 usable hosts. A /26 therefore splits one /24 into four blocks of 64 addresses.
Common mistakes
- Counting all 232 − n addresses as hosts: two of them, the network and broadcast addresses, cannot be assigned to devices.
- Confusing the subnet mask with the wildcard mask: ACL syntax on some routers expects the wildcard (0.0.0.63), not 255.255.255.192.
- Entering the mask itself (255.255.255.0) instead of the prefix length (24); the field takes the number after the slash.
- Expecting a bigger prefix to mean a bigger network: /28 is smaller than /24 because fewer bits are left for hosts.
- Reading 0 usable hosts for /31 as an error: the tool applies the standard minus-two rule, so check whether your equipment allows /31 point-to-point links.
About this calculator
CIDR notation (Classless Inter-Domain Routing) expresses a subnet mask as a slash followed by the number of leading 1-bits — /24 means the first 24 bits of the 32-bit address are the network portion. This converts a prefix length directly into the dotted-decimal subnet mask everyone actually configures on routers and servers (/24 = 255.255.255.0), plus the wildcard mask (its bitwise inverse, used in Cisco ACLs) and the count of usable host addresses.
CIDR replaced the old rigid Class A/B/C system in the 1990s to make IP address allocation far more efficient, and converting between prefix length and subnet mask is a daily task for network administrators configuring VLANs, firewalls, and routing tables, and a core topic in every networking certification syllabus.
Was this helpful?
You can pick up to 3 reactions.
Popular calculators
Loan Calculator
Monthly payment, total interest and full amortization schedule.
Percentage Calculator
Percent change, percent of, and ratio calculations.
Discount Calculator
Calculate final price, savings, and discount amount.
BMI Calculator
Body mass index from height and weight (metric or imperial).
Age Calculator
Compute your exact age in years, months and days from a birth date.
Compound Interest Calculator
Calculate the final amount and interest earned with compounding.
All Calculators
- Loan Calculator
- Profit Calculator
- Discount Calculator
- BMI Calculator
- Percentage Calculator
- Ideal Weight Calculator
- Age Calculator
- Pregnancy Due Date Calculator
- Compound Interest Calculator
- BMR Calculator (Basal Metabolic Rate)
- Tip Calculator
- Fuel Cost Calculator
- Date Difference Calculator
- Sleep Cycle Calculator
- Daily Water Intake Calculator
- Simple Interest Calculator
- Heart Rate Zones Calculator
- Running Pace Calculator
- Pet Age Calculator
- Calories Burned Calculator
- Macro Calculator
- TDEE Calculator (Total Daily Energy Expenditure)
- Waist-to-Hip Ratio Calculator
- Honor Roll Calculator
- One Rep Max (1RM) Calculator
- Ovulation Calculator
- Electricity Cost Calculator
- Unit Price Calculator
- Savings Goal Calculator
- Break-Even Point Calculator
- Paint Calculator
- Course Grade Average Calculator
- Business Days Calculator
- Time Duration Calculator
- Fuel Economy Calculator
- Temperature Converter
- Tile Calculator
- Aspect Ratio Calculator
- Roman Numeral Converter
- Goal Weight Timeline Calculator
- Salary Converter (Hourly to Annual)
- Credit Card Validator (Luhn)
- Body Surface Area (BSA) Calculator
- Feels-Like Temperature Calculator
- Ohm’s Law Calculator
- PPI (Pixel Density) Calculator
- Molar Mass Calculator
- Zodiac Sign Calculator (Western + Chinese)
- IBAN Validator
- Shoe Size Converter
- Country Info & Dialing Code Lookup
- Time Zone Difference (World Clock)
- CAGR (Compound Annual Growth Rate) Calculator
- Rule of 72 Calculator
- Blood Alcohol Content (BAC) Calculator
- Lean Body Mass (LBM) Calculator
- Pythagorean Theorem Calculator
- Speed Converter
- Download Time Calculator
- Date Calculator (Add/Subtract)
No calculators found
Comments (1)
Use the host count to size a subnet before you carve it up. A /22 gives mask 255.255.252.0 and 1,022 usable hosts, while a /30 leaves exactly 2, which is why it shows up on router-to-router links. The usable figure only subtracts the network and broadcast addresses, so some cloud platforms that reserve more addresses per subnet will give you fewer. Which provider or vendor rules would you like us to mention next?