IPv4 guide

How to convert an IP address to binary and decimal formats

IP addresses identify devices on a network. An address contains a network part and a host part: the network part identifies the network, while the host part identifies a device or interface within it.

IPv4 addresses contain four decimal octets separated by dots, such as 192.168.1.1. IPv6 addresses are longer and use colon-separated hexadecimal groups, but this guide focuses on IPv4.

Step 1: understand the IPv4 format

An IPv4 address is a 32-bit value split into four 8-bit octets. Each octet is written as a decimal number from 0 through 255.

Step 2: convert each decimal octet to binary

Convert each octet separately, then add leading zeroes until every result is eight bits long. For 192.168.1.1:

192 = 11000000
168 = 10101000
  1 = 00000001
  1 = 00000001

Step 3: combine the four octets

Keep the dots between octets so the 32-bit result remains easy to read:

11000000.10101000.00000001.00000001

Step 4: convert binary octets back to decimal

For each 8-bit octet, add the place values whose bits are 1. The place values from left to right are 128, 64, 32, 16, 8, 4, 2, 1.

Binary octetCalculationDecimal
11000000128 + 64192
10101000128 + 32 + 8168
0000000111

Writing those decimal octets with dots gives 192.168.1.1.

More worked examples

10.0.0.1
00001010.00000000.00000000.00000001

172.16.0.1
10101100.00010000.00000000.00000001

Exercises

  • Convert 192.168.1.10 to binary.
  • Convert 00001010.00001010.00001010.00001010 to dotted decimal.
  • Convert 172.16.0.1 to binary.
  • Convert 11000000.10101000.00000000.11111111 to dotted decimal.
  • Convert 172.31.255.255 to binary.
  • Convert 11111111.11111111.11111111.00000000 to dotted decimal.
  • Convert 198.51.100.0 to binary.
  • Convert 11110000.00000000.00000000.00000000 to dotted decimal.

Open the format converter