Decimal to IP Converter
Convert decimal numbers to IPv4 addresses and IP addresses to integers.
Decimal to IP Converter
Convert an integer into a dotted IPv4 address and an IPv4 address into its integer value. Paste one value per line: 3232235521 becomes 192.168.0.1, 2130706433 becomes 127.0.0.1, and 8.8.8.8 becomes 134744072.
The formula
An IPv4 address a.b.c.d is a 32-bit number, so its decimal value is:
a × 16,777,216 + b × 65,536 + c × 256 + d
(the multipliers are 256³, 256², 256¹, and 256⁰). For 192.168.0.1 that is 192 × 16,777,216 + 168 × 65,536 + 0 × 256 + 1 = 3,232,235,521.
To go back, divide by 16,777,216 for the first octet, take the remainder and divide by 65,536 for the second, and so on. Valid values range from 0 (0.0.0.0) to 4,294,967,295 (255.255.255.255).
Why store IP addresses as integers?
- Databases – an unsigned 32-bit integer column needs 4 bytes instead of up to 15 characters, and range queries such as "is this IP inside a block" become simple
BETWEENcomparisons. MySQL'sINET_ATON()andINET_NTOA()perform exactly this conversion. - GeoIP and blocklists – IP-to-country databases such as MaxMind CSV exports and IP2Location list ranges as start and end integers.
- Sorting – sorting addresses as text puts
10.0.0.10before10.0.0.9; sorting their integer values gives the correct order. - Logs and analytics – some systems log client addresses as integers, which you need to convert back for investigation.
Tips
- Thousands separators and spaces in the decimal input are ignored (
3,232,235,521works). - Numbers larger than 4,294,967,295 are rejected because they do not fit into IPv4.
- A single decimal number is also a valid host in most browsers:
http://3232235521/openshttp://192.168.0.1/.
For other notations, try Hex to IP, Binary to IP, or Octal to IP; to work with whole networks, use the CIDR Calculator.
Frequently Asked Questions
How do I convert an IP address to a decimal number?
Multiply the first octet by 16,777,216, the second by 65,536, the third by 256, and add all four results. 10.0.0.1 = 167,772,161.
What is the largest decimal value for an IPv4 address?
4,294,967,295, which is 255.255.255.255 (2^32 − 1).
Is this the same as MySQL INET_ATON?
Yes. IP to Decimal gives the same result as INET_ATON(), and Decimal to IP matches INET_NTOA().