IP to Decimal Converter
Convert an IP address to decimal, hex, binary and octal, or type any of those numbers to get the IP back. Each octet is drawn as 8 bits with their place values, so you can follow the arithmetic.
Read as dotted
| Octet | 1286432168421 | Hex |
|---|---|---|
| 198 | 11000110 | C6 |
| 128+64+4+2 × 256³ = 3,321,888,768 | ||
| 51 | 00110011 | 33 |
| 32+16+2+1 × 256² = 3,342,336 | ||
| 100 | 01100100 | 64 |
| 64+32+4 × 256 = 25,600 | ||
| 77 | 01001101 | 4D |
| 64+8+4+1 × 1 = 77 | ||
| Total | ||
| = 3,325,256,781 | ||
An IP, or its decimal, hex, binary or octal number to get the IP back. Converted in your browser; nothing is sent.
3325256781
The same number in code
SELECT INET_ATON('198.51.100.77');3325256781SELECT '198.51.100.77'::inet - '0.0.0.0'::inet;3325256781int(ipaddress.ip_address('198.51.100.77'))3325256781ip2long('198.51.100.77')3325256781- Dotted decimal
- Decimal
- Hex
- Binary octets
- Octal
- Hex octets
- Octal octets
- In a browser (each opens 198.51.100.77)
- Reverse DNS name
- As IPv6 (mapped)
- IPv4 → IPv6
How do I convert an IP address to decimal?
Multiply the four numbers by 256³, 256², 256 and 1 and add them up: 192.168.1.1 is 192 × 16,777,216 + 168 × 65,536 + 1 × 256 + 1 = 3,232,235,777.
An IPv4 address is one 32-bit number written in four 8-bit pieces, so the dotted form and the decimal form are the same value. MySQL's documentation uses 10.0.5.9 = 167773449 as its example.

Any form inDotted, decimal, hex, binary, octal or a URL: the field reads them all.Bits and place valuesEach 1 adds its place value: 128 + 64 + 4 + 2 = 198.× 256³, 256², 256, 1Each octet times its weight, then the total.Every form outHex, binary, octal and the URLs browsers accept, each with copy.The numberThe whole address as one 32-bit number, ready to copy, with what kind of address it is.How do I convert decimal to an IP address?
Divide by 16,777,216, then divide the remainder by 65,536, then by 256: the three quotients and the last remainder are the four numbers, so 3232235777 is 192.168.1.1.
Type the number in the converter and it does the same, along with hex, binary, octal and the forms browsers accept. Numbers above 4,294,967,295 aren't IPv4 addresses; the converter reads them as IPv6 numbers and says so.
3,232,235,777÷ 16,777,216=192remainder 11,010,30511,010,305÷ 65,536=168remainder 257257÷ 256=1remainder 11÷ 1=1remainder 0192.168.1.1
How do I convert an IP address to binary?
Write each of the four numbers as 8 bits with the place values 128, 64, 32, 16, 8, 4, 2 and 1: 192 is 128 + 64, so 11000000, and 192.168.1.1 is 11000000.10101000.00000001.00000001.
Go through the place values from the left: write 1 and subtract when the value fits, otherwise write 0. For 168: 128 fits (40 left), 64 doesn't, 32 fits (8 left), 16 doesn't, 8 fits, so 10101000. Back from binary, add the place values of the 1s.
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 | ||
|---|---|---|---|---|---|---|---|---|---|
| 192 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 128 + 64 |
| 168 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 128 + 32 + 8 |
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 |
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 |
11000000.
How do I convert an IP address to hex?
Split each octet's 8 bits into two halves of 4 and write each half as one hex digit: 192 is 1100 0000, which is C0, so 192.168.1.1 is 0xC0A80101.
Hex is also how IPv6 writes an embedded IPv4 address: ::ffff:c0a8:101 is 192.168.1.1. Browsers accept the hex number as a host: http://0xC0A80101/ opens 192.168.1.1.
11000000C010101000A8000000010100000001010xC0A80101
4 bits = 1 hex digit
Why does http://3232235777 open 192.168.1.1?
Because browsers read a host made only of numbers as an IPv4 address in any of the old inet_aton forms, one decimal number included, and then load the dotted address.
Each part may be decimal (the URL Standard), hex with 0x or octal with a leading 0, and fewer than four parts let the last one fill the remaining bytes. So http://192.168.1/ opens 192.168.0.1, not 192.168.1.1. ping and curl accept the same forms.
Numbers past 32 bits, an 8 or 9 in a part that starts with 0, and a fifth part are refused.
| Typed in the address bar | Opens |
|---|---|
http://3232235777/ | 192.168.1.1 |
http://0xC0A80101/ | 192.168.1.1 |
http://0300.0250.1.1/ | 192.168.1.1 |
http://127.1/ | 127.0.0.1 |
http://192.168.1/ | 192.168.0.1 |
http://4294967296/ | Refused |
http://09/ | Refused |
http://192.0.2.1.5/ | Refused |
Why do alternate IP address forms matter for security?
Because a filter that compares addresses as text can be fooled: 2130706433, 0x7f.1, 127.1 and ::ffff:127.0.0.1 are all 127.0.0.1, so filters must compare the numeric value, not the string.
OWASP lists these encodings among the ways around SSRF defences. Libraries have shipped this bug: the npm packages netmask and ip, Python's ipaddress and Go's net package all misread leading zeros or alternate forms at some point and have since been fixed.
Parse with a strict reader, convert to a number, then compare ranges. Block IPv4-mapped addresses of blocked ranges too.
deny 127.0.0.1
Compared as text
127.0.0.1blocked
2130706433gets through
0x7f.1gets through
127.1gets through
::ffff:127.0.0.1gets through
Compared as a number
127.0.0.12130706433 · blocked
21307064332130706433 · blocked
0x7f.12130706433 · blocked
127.12130706433 · blocked
::ffff:127.0.0.12130706433 · blocked
How do I convert an IPv6 address to decimal?
The same way with eight 16-bit groups: 2001:db8::1 is 42540766411282592856903984951653826561, a number of up to 39 digits that needs BigInt in JavaScript.
There are 2^128 IPv6 addresses. JavaScript numbers hold integers exactly only up to 2^53 − 1, so ordinary arithmetic silently rounds IPv6 values. Python's int(ipaddress.ip_address(…)) is exact.
2001:db8::1
42540766411282592856903984951653826561
exact (BigInt)
42540766411282592856903984951653826560
Number(): rounded after 2^53
How do I convert IP addresses to numbers in code and databases?
Use the platform's own functions with an unsigned type: MySQL's INET_ATON() into INT UNSIGNED, PostgreSQL's inet subtraction, Python's int(ipaddress.ip_address(…)), and >>> 0 after shifts in JavaScript.
A signed 32-bit integer can't hold addresses from 128.0.0.0 up: JavaScript's << gives -1062731519 for 192.168.1.1, and PHP's ip2long() goes negative on 32-bit builds. For IPv6, MySQL uses INET6_ATON() and VARBINARY(16).
› SELECT INET_ATON('192.168.1.1'), INET_NTOA(3232235777); 3232235777 | 192.168.1.1
MySQL 8.4
› SELECT '192.168.1.1'::inet - '0.0.0.0'::inet, '0.0.0.0'::inet + 3232235777; 3232235777 | 192.168.1.1
PostgreSQL 16
› import ipaddress int(ipaddress.ip_address('192.168.1.1')), ipaddress.IPv4Address(3232235777) (3232235777, IPv4Address('192.168.1.1'))
Python ipaddress
› '192.168.1.1'.split('.').reduce((n, o) => (n << 8) | +o, 0) >>> 0 3232235777
JavaScript
› echo ip2long('192.168.1.1'), ' ', long2ip(3232235777); 3232235777 192.168.1.1
PHP 8
Frequently asked questions
What is 192.168.1.1 in decimal?
What is the largest decimal value of an IPv4 address?
How do I convert 3232235777 back to an IP address?
What does a leading zero like 010 mean in an IP address?
Why does 192.168.1 open 192.168.0.1?
How do I convert an IP address to binary by hand?
How do I store IP addresses as numbers in MySQL?
Why is my IP number negative in JavaScript or PHP?
Can an IPv6 address be converted to decimal?
Is http://0x7f000001/ the same as 127.0.0.1?
Missing something?Suggest a feature or a new tool
Related tools
IPv6 to IPv4
Find the IPv4 address inside an IPv6 one: mapped, NAT64, 6to4, Teredo and ISATAP, bit by bit
IPv4 to IPv6
Every IPv6 form of an IPv4 address: mapped, NAT64 and 6to4, each marked in use or rare
IPv6 Compression
Shorten or expand IPv6 addresses the RFC 5952 way and see which rule removed each zero
What Is My IP
Your public IPv4 and IPv6 at once, with the network, location and a VPN check
IPv6 Test
Test if your IPv6 works, which family your browser picks and if a site has IPv6
Subnet Calculator
Network, broadcast, usable hosts and masks for any IPv4 or IPv6 block, plus VLSM, splits and cloud subnets
Reverse DNS Lookup
Find hostnames associated with any IP address via PTR records
DNS Lookup
Every DNS record from the domain's own nameservers, beside Google's and Cloudflare's cache