Subnet Mask to CIDR Converter
Enter a dotted subnet mask to get its CIDR prefix length.
Result
How it is calculated
The four octets of the dotted mask are written as 8-bit binary and joined into one 32-bit string. A valid subnet mask is a run of 1s followed by a run of 0s, and the CIDR prefix is the number of 1s: prefix = count of 1-bits. The usable host count is 2(32 − prefix) − 2, which reserves the network and broadcast addresses. The wildcard mask is each octet subtracted from 255, which is the bitwise inverse. The mask needs exactly four numbers from 0 to 255 separated by dots; surrounding spaces are ignored. Masks whose bits are not contiguous, such as 255.0.255.0, an inverted mask such as 0.0.0.255, a slash form such as /24, or a value over 255 give no result. For /31 the tool shows 2 usable hosts, because a point-to-point link between two routers uses both addresses (RFC 3021), and for /32 it shows 1, a single host address. IPv4 only.
Worked example
Take the mask 255.255.255.224. The last octet 224 is 11100000 in binary, so the full mask has 8 + 8 + 8 + 3 = 27 ones. The tool shows /27. That leaves 32 − 27 = 5 host bits, so 25 − 2 = 32 − 2 = 30 usable hosts. The wildcard is 255 − 255, 255 − 255, 255 − 255 and 255 − 224, giving 0.0.0.31. A /27 therefore splits a /24 network into eight blocks of 32 addresses.
Common mistakes
- Typing the wildcard mask instead of the subnet mask. 0.0.0.255 has its 1s at the end, so it is rejected; the subnet mask for the same network is 255.255.255.0.
- Entering the prefix itself, such as /24 or 24. This tool expects four dotted numbers, so a prefix gives no result.
- Using a mask with a gap, like 255.255.0.255. Every 1-bit must come before every 0-bit; masks that break this are not valid subnet masks.
- Counting all addresses as hosts. Out of the 32 addresses in a /27, two are reserved and 30 are usable, and the tool already subtracts them.
- Applying the 2ⁿ − 2 rule by hand to /31 and /32: they are special cases with 2 and 1 usable addresses, which is what the tool shows.
Sources
About this calculator
A dotted-decimal subnet mask like 255.255.255.0 and its CIDR notation /24 describe the exact same thing: the mask, converted to binary, is a run of consecutive 1-bits followed by 0-bits, and the CIDR prefix is simply the count of those leading 1-bits. A /24 mask leaves 8 host bits, giving 256 total addresses and 254 usable host addresses after reserving the network and broadcast address.
Network engineers and system administrators convert between the two notations constantly when configuring routers, firewalls, and subnets, since older tools and documentation often use dotted masks while modern configs favor CIDR.
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)
For sizing, work from the number of devices. About 500 hosts need nine host bits, which means a /23, mask 255.255.254.0, with 510 usable addresses; type that mask to confirm the prefix and host count. If a mask your equipment shows gets rejected here, post it so others can see the pattern. Which mask formats confuse you most?