Decimal to IP: turn an integer back into an address
Databases, analytics exports and IP-range datasets often store an IPv4 address as a plain number such as 3232235777. A decimal to IP conversion splits that number back into four octets so you can read it, ping it or paste it into a firewall rule.
Decoding by repeated division
Divide by the place values of base 256 and keep the remainders:
3232235777 ÷ 16,777,216 = 192 remainder 11,010,305
11010305 ÷ 65,536 = 168 remainder 257
257 ÷ 256 = 1 remainder 1
last octet = 1
→ 192.168.1.1
Programmers usually do the same thing with bit shifts. In JavaScript, [n >>> 24, (n >>> 16) & 255, (n >>> 8) & 255, n & 255].join('.') produces the dotted form: shift the wanted byte to the bottom, then mask off everything above it.
Examples
2130706433 → 127.0.0.1
167772414 → 10.0.0.254
16777216 → 1.0.0.0
0 → 0.0.0.0
4294967295 → 255.255.255.255
The value 16777216 is exactly 256³, which is why it decodes to 1.0.0.0: each step of 256³ moves the first octet by one.
Integer addresses are common in IP-to-location tables and log pipelines, which key each row by a start and end number so that a lookup is a single numeric comparison. Decoding a few rows by hand is a quick way to confirm you are reading the right columns.
Input rules and common errors
- Only digits. Thousands separators such as
3,232,235,777are rejected; remove them first. - Range 0–4294967295. Anything larger needs more than 32 bits and cannot be an IPv4 address.
- Negative numbers. A value like -1062731519 comes from storing the address in a signed 32-bit field. Add 4,294,967,296 and you get 3232235777, which is 192.168.1.1.
- Byte order. If a result looks reversed (for example 1.1.168.192), the number was built from little-endian bytes. Converting it to hex with Decimal to Hex makes the byte order easy to spot.
Decimal IP addresses in databases, code and URLs
You rarely need to decode integers by hand, because most platforms have a built-in function. These are handy when you move from a quick check here to a query or a script:
- MySQL:
INET_NTOA(3232235777)returns'192.168.1.1', andINET_ATON()goes back. - PostgreSQL:
'0.0.0.0'::inet + 3232235777gives192.168.1.1. - Python:
str(ipaddress.IPv4Address(3232235777)).
Browsers accept the same trick: the URL parser reads a host written as a single number, so http://2130706433/ opens 127.0.0.1. Phishing links sometimes use this form to hide where they point. If you see a long number where a domain should be, decode it here to find the real address before you click.
Related tools
Going the other way is handled by IP to Decimal. If your data stores ranges as a start and end integer, decode both ends here and then check the block with the CIDR calculator. All conversions run locally in your browser.