Skip to main content

Hex to IP address

By Oakgen Team · Updated

Quick answer

Split the 8 hex digits into four pairs and convert each pair to decimal. C0A80001 becomes C0=192, A8=168, 00=0, 01=1, so 192.168.0.1.

Hexadecimal to IPv4 address

IPv4 address

192.168.0.1
Well-known IPv4 addresses in hex
AddressHexWhat it is
127.0.0.17F000001Loopback (127.0.0.0/8)
10.0.0.10A000001Private use (10.0.0.0/8)
172.16.0.1AC100001Private use (172.16.0.0/12)
192.168.0.1C0A80001Private use (192.168.0.0/16)
255.255.255.255FFFFFFFFLimited broadcast

Why it is four pairs

RFC 791 defines IPv4 addresses as four octets, 32 bits in all. One octet is one byte, which is two hex digits, so a whole address is eight hex digits. Dotted decimal, the form people read, writes each octet as a number from 0 to 255 (RFC 3986 gives that syntax).

Check the example: 192.168.0.1 is C0A80001, and 127.0.0.1 is 7F000001. Shorter inputs are padded on the left with zeros, so 1 becomes 0.0.0.1.

Hex inside addresses

The POSIX inet_addr function accepts a leading 0x as hexadecimal for any part of an address, a leading 0 as octal and otherwise decimal. With a single number the value is stored directly, which is why 0xC0A80001 can stand for 192.168.0.1 in tools that follow POSIX. Do not rely on it when you write configuration: leading zeros are read as octal, a common source of mistakes.

Special ranges to recognise

RFC 1918 reserves 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16 for private use. RFC 1122 reserves 127.0.0.0/8 for loopback, and the all-ones address is the limited broadcast. IPv6 is different: addresses are 128 bits written as up to eight groups of one to four hex digits, so this converter covers IPv4 only.

Do more with Oakgen Agent

The Agent can convert a long list in its code sandbox and label private, loopback and broadcast addresses.

Open in Oakgen Agent

The prompt is filled in for you. Nothing is sent until you press send in the Agent.

FAQ

What is 0xC0A80001 as an IP address?

192.168.0.1, a private address.

How do I convert an IP address to hex?

Convert each of the four numbers to two hex digits and join them. 10.0.0.1 becomes 0A000001. Use the Swap button above.

Can I convert IPv6 here?

No. IPv6 addresses are 128 bits and are already written in hex groups.

Why are 192.168.x.x addresses special?

RFC 1918 reserves that block for private networks, so those addresses are not routed on the public internet.

Sources