StringMash.com

IP address to binary

Each of the four numbers becomes 8 bits, with the working.

Conversion
12 characters
Updates as you type
Binary11000000.10101000.00000001.00001010
As one 32-bit number11000000101010000000000100001010
Decimal integer3232235786
Hex0xC0A8010A
RangePrivate-Use (RFC 1918)
Swap to turn binary into an address

Show the steps
128164132016080402010192128164032116081402010168128064032016080402011112806403201608140211010
  1. Each of the four numbers is one byte, so each becomes 8 bits. Write each as a sum of the place values 128, 64, 32, 16, 8, 4, 2 and 1, taking the biggest that fits each time; every value used is a 1.
  2. 192 = 128 + 64 → 11000000
  3. 168 = 128 + 32 + 8 → 10101000
  4. 1 = 1 → 00000001
  5. 10 = 8 + 2 → 00001010
  6. Together: 11000000.10101000.00000001.00001010.

Using it

Type an IPv4 address, or several, one per line. Each comes out as four groups of 8 bits, and a /prefix on the end is kept. The working shows how each number splits into place values, and the rows give the same address as one 32-bit number, a decimal integer and hex, with the kind of range it's in.

Swap the boxes to go the other way: four groups of up to 8 bits with dots or spaces between, or 32 bits in a row.

How it works

An IPv4 address is 32 bits. Written the usual way, it's split into four bytes of 8 bits, and each byte is written as a decimal number from 0 to 255. Converting to binary undoes that, one byte at a time.

Each of the 8 bits has a place value: 128, 64, 32, 16, 8, 4, 2 and 1. To convert a number, go along from 128 and take each value that still fits, subtracting it as you go. Every value you take is a 1, every value you skip a 0.

A worked example

Take 192.168.1.10. 192 is 128 + 64, so 11000000. 168 is 128 + 32 + 8, so 10101000. 1 is just the last place: 00000001. 10 is 8 + 2: 00001010.

Put together, 192.168.1.10 is 11000000.10101000.00000001.00001010. Each group keeps its leading zeros, so every group is exactly 8 bits and the whole address is 32.

The octets in subnet masks

A mask's ones all come first, so only these nine values appear in a mask's octets.
DecimalBinaryOnes
0000000000
128100000001
192110000002
224111000003
240111100004
248111110005
252111111006
254111111107
255111111118

Why convert to binary

Subnetting happens in binary. A /24 means the first 24 bits name the network, and 255.255.255.0 is that written as a mask: 24 ones, then 8 zeros. The network address is the address ANDed with the mask, bit by bit. The subnet calculator shows that AND for any address and prefix.

Questions

What is 255.255.255.0 in binary?

11111111.11111111.11111111.00000000: 24 ones and 8 zeros, which is why it's the same as /24.

Why does each part have 8 digits?

Each of the four numbers is one byte, 8 bits. Leading zeros keep every byte the same width, so 1 is written 00000001.

Does it convert IPv6?

No, only IPv4. An IPv6 address is 128 bits, already written in hex, where each hex digit is 4 bits.

Sources

Added . What's new