IP address to binary converter

An IPv4 address is a 32-bit number written as four 8-bit octets, so 192.168.1.10 is 11000000.10101000.00000001.00001010 in binary. Enter an address in dotted decimal, binary, a single integer or hex to see every form with the working.

Dotted decimal (192.168.1.10), dotted binary (11000000.10101000.00000001.00001010), all 32 bits in a row, one decimal number (3232235786) or hex (0xC0A8010A or C0.A8.01.0A). The format is detected for you.

In binary

11000000.10101000.00000001.00001010

Read as dotted decimal · 3,232,235,786 as one number

Dotted decimal
192.168.1.10
Dotted binary
11000000.10101000.00000001.00001010each octet as 8 bits
32-bit binary
11000000101010000000000100001010the same 32 bits without dots
Decimal integer
32322357863,232,235,786; MySQL's INET_ATON() returns this number
Hexadecimal
0xC0A8010Atwo hex digits per octet
Hexadecimal, dotted
C0.A8.01.0A0xC0.0xA8.0x01.0x0A with prefixes
Each octet of 192.168.1.10 as 8 bits: add the place values that hold a 1
OctetDecimal1286432168421Sum of the 1s
1st19211000000128 + 64 = 192
2nd16810101000128 + 32 + 8 = 168
3rd1000000011
4th10000010108 + 2 = 10
  • 192.168.1.10 is in 192.168.0.0/16, private-use (RFC 1918).

How do you convert an IP address to binary?

An IPv4 address is a 32-bit number; RFC 791 defines addresses as a fixed four octets. Dotted decimal writes each 8-bit octet as a number from 0 to 255, so converting to binary means writing each of the four numbers as exactly 8 bits and keeping the dots: 192 is 11000000, 168 is 10101000, 1 is 00000001 and 10 is 00001010.

To convert one octet by hand, take the place values 128, 64, 32, 16, 8, 4, 2 and 1 from the left. Write 1 under each value you can subtract from what is left of the number, and 0 under the rest: 168 is 128 + 32 + 8, so it is 10101000. Always keep all eight digits, including the leading zeros, or the bits of the next octet shift into the wrong places.

The same 32 bits can be read as one number: the first octet × 256³ + the second × 256² + the third × 256 + the fourth, so 192.168.1.10 is 3,232,235,786. That is the integer MySQL's INET_ATON() returns, and the form to store in an unsigned 32-bit column. In hex, each octet is two digits: 192.168.1.10 is 0xC0A8010A.

This converter refuses parts with leading zeros, such as 192.168.010.1. The C library's inet_aton reads a part that starts with 0 as octal, so 010 is 8 there, not 10; Python's ipaddress module has rejected leading zeros since version 3.9.5 to avoid that confusion. Short forms such as 127.1, which inet_aton accepts as 127.0.0.1, are also refused: write all four octets.

place values:  128 (2⁷)  64 (2⁶)  32 (2⁵)  16 (2⁴)  8 (2³)  4 (2²)  2 (2¹)  1 (2⁰)
192 = 128 + 64             →  11000000
168 = 128 + 32 + 8         →  10101000
192.168.1.10  →  11000000.10101000.00000001.00001010
as one number = 192 × 256³ + 168 × 256² + 1 × 256 + 10 = 3,232,235,786

What are the place values of an octet and some well-known addresses in binary?

The eight place values of an octet, then notable IPv4 addresses in binary, hex and as one number
DecimalBinaryHexNotes
12810000000802⁷: bit 1 of the octet, counting from the left
6401000000402⁶: bit 2 of the octet, counting from the left
3200100000202⁵: bit 3 of the octet, counting from the left
1600010000102⁴: bit 4 of the octet, counting from the left
800001000082³: bit 5 of the octet, counting from the left
400000100042²: bit 6 of the octet, counting from the left
200000010022¹: bit 7 of the octet, counting from the left
100000001012⁰: bit 8 of the octet, counting from the left
25511111111FFall eight bits set, the largest octet (128 + 64 + 32 + 16 + 8 + 4 + 2 + 1)
0.0.0.000000000.00000000.00000000.0000000000.00.00.00“This host on this network” (RFC 1122); 0 as one number
127.0.0.101111111.00000000.00000000.000000017F.00.00.01Loopback, this computer (RFC 1122); 2,130,706,433 as one number
10.0.0.100001010.00000000.00000000.000000010A.00.00.01Private-use (RFC 1918); 167,772,161 as one number
192.168.1.111000000.10101000.00000001.00000001C0.A8.01.01Private-use (RFC 1918); 3,232,235,777 as one number
255.255.255.25511111111.11111111.11111111.11111111FF.FF.FF.FFLimited broadcast (RFC 919, RFC 8190); 4,294,967,295 as one number

How to convert an IP address to binary

  1. 1
    Enter the addressType or paste an IPv4 address in any common form: 192.168.1.10, 11000000.10101000.00000001.00001010, 3232235786 or 0xC0A8010A.
  2. 2
    Check the detected formatThe result says how your input was read, such as dotted decimal or dotted binary, and explains anything it refused, such as a leading zero or an octet over 255.
  3. 3
    Copy the form you needCopy the dotted binary, the 32 bits in a row, the single decimal number or the hex form from the result.
  4. 4
    Follow the workingThe octet table shows which of the place values 128 to 1 are set in each octet and how they add up.

Frequently asked questions

How do I convert an IP address to binary by hand?
Do one octet at a time. Starting from 128, write 1 if the place value fits into what is left of the octet and subtract it, otherwise write 0, then move on to 64, 32 and so on down to 1. 10 becomes 00001010 (8 + 2). Keep all eight digits per octet and put the dots back between them.
What is 192.168.1.1 in binary?
11000000.10101000.00000001.00000001. 192 is 128 + 64, 168 is 128 + 32 + 8, and each 1 is 00000001; as one 32-bit number it is 3,232,235,777, or 0xC0A80101 in hex.
Why does each part of an IPv4 address stop at 255?
Each part is one octet, 8 bits, and 8 bits hold 2⁸ = 256 different values: 0 to 255. Four octets make the 32 bits RFC 791 specifies, which is why there are 4,294,967,296 IPv4 addresses in total and 256 or more in a part is invalid.
Why is an IP address sometimes stored as one big number?
Because it is a 32-bit number underneath, and an integer is smaller and faster to compare or sort than text. MySQL's INET_ATON('10.0.5.9') returns 167773449 (10 × 256³ + 0 × 256² + 5 × 256 + 9), and MySQL's manual says to keep it in an INT UNSIGNED column, since a signed INT can't hold addresses whose first octet is over 127.
Why are leading zeros not allowed in an IP address?
Because they can change the address. The C library function inet_aton treats a part that starts with 0 as octal, so 192.168.010.1 is 192.168.8.1 to it, not the 192.168.10.1 it looks like. Python's ipaddress module has rejected leading zeros since version 3.9.5 to prevent confusion with octal, and this converter refuses them too.

Sources

Related tools

See all 73 free tools

Need a custom dev tool for your team?

We build internal tools, dashboards, APIs, and SaaS platforms. If you can describe it, we can ship it.

Built by CountryDevs · No signup · No ads · We count visits, never what you enter