IP to Hex Converter
Convert an IPv4 address to its eight-digit hexadecimal form. Both the bare value and the 0x-prefixed programming literal are shown, along with the per-octet working.
Why hex and IPv4 line up so well
Hexadecimal is base 16, and 16 is 2 to the fourth power, so every hex digit maps to exactly four bits with no rounding. That makes hex a compact, lossless shorthand for binary. Since an IPv4 octet is eight bits, it is always exactly two hex digits — no padding rules, no ambiguity, no exceptions.
Octet 192 168 1 1 Bits 11000000 10101000 00000001 00000001 Nibbles 1100 0000 1010 1000 0000 0001 0000 0001 Hex C 0 A 8 0 1 0 1 Result C0A80101
Splitting each octet into two nibbles is the bridge between binary and hex. The first nibble is the high four bits and the second is the low four bits.
Converting a decimal octet to hex by hand
Divide the decimal value by 16. The quotient is the first hex digit and the remainder is the second. Both are then written using 0-9 for 0-9 and A-F for 10-15.
Example: converting 172 and 16
172 ÷ 16 = 10 remainder 12. Ten maps to A and twelve maps to C, so 172 is AC. Then 16 ÷ 16 = 1 remainder 0, giving 10. The pair 172.16 therefore becomes AC10.
172.16.0.1 → AC100001 → 0xAC100001
A useful sanity check: the first hex digit of the first octet tells you the class. First digits 0 and 1 mean a first octet below 32, C and D mean 192-223, and E and F mean 224 or above, which is multicast or reserved.
Where hexadecimal addresses appear
- Packet captures and protocol headers. Wireshark shows addresses in both dotted-decimal and hex, and the IP header itself stores them as raw bytes — which is why a hex editor shows C0 A8 01 01 for 192.168.1.1.
- Firewall and routing tables. Several platforms store address ranges as hex or as hex-masked pairs, because the mask operation is a single bitwise AND on a machine word.
- IPv4-mapped IPv6 addresses. The 32-bit form appears as the last eight hex digits, so ::ffff:C0A80101 is the IPv6 representation of 192.168.1.1.
- Source code and configuration. Any place a 32-bit literal is needed, the 0x prefix disambiguates it from decimal.
Common mistakes
- Dropping leading zeros in a pair. The octet 1 is 01, not 1. A missing digit shifts every subsequent pair and produces a wrong address.
- Mixing up 10 and A. The decimal number 10 becomes a single hex digit A, not the two digits "10". Writing 10 where A belongs gives a nine-digit value.
- Reversing the byte order. C0A80101 is not the same as 0101A8C0. Endianness conversions are a separate operation, usually performed on the 32-bit integer rather than on the text form.
- Forgetting the prefix in code. A literal 10101010 with no 0x is a decimal number, not the byte value 170.
Also: IP to Binary Converter · Binary to IP Converter · Hex to IP Converter · IP to Decimal Converter · Decimal to IP Converter
Reference: common addresses in hex
| Address | Description | Hex | 0x literal |
|---|---|---|---|
| 0.0.0.0 | Unspecified / default route | 00000000 | 0x00000000 |
| 10.0.0.1 | First host of the 10/8 private block | 0A000001 | 0x0A000001 |
| 127.0.0.1 | Loopback | 7F000001 | 0x7F000001 |
| 169.254.1.1 | Link-local (APIPA) | A9FE0101 | 0xA9FE0101 |
| 172.16.0.1 | First host of the 172.16/12 private block | AC100001 | 0xAC100001 |
| 192.168.0.1 | Common home gateway | C0A80001 | 0xC0A80001 |
| 192.168.1.1 | Common home gateway | C0A80101 | 0xC0A80101 |
| 198.51.100.1 | RFC 5737 documentation range | C6336401 | 0xC6336401 |
| 8.8.8.8 | Public DNS resolver | 08080808 | 0x08080808 |
| 255.255.255.255 | Limited broadcast | FFFFFFFF | 0xFFFFFFFF |
Reverse direction: hex to IP. Other conversions: IP to binary, IP to decimal, full IP converter.
Frequently asked questions
How do I convert an IP address to hexadecimal?
Convert each octet to two hex digits and concatenate them. For 192.168.1.1: 192 is C0, 168 is A8, 1 is 01 and 1 is 01, giving C0A80101. Each octet is exactly one byte, and one byte is exactly two hex digits, so an IPv4 address is always eight hex digits.
Why is each octet two hex digits?
One hex digit represents four bits, so two hex digits represent eight bits — exactly one octet. A single hex digit can express 16 values (0-9 and A-F) and 2^4 = 16, which is why the base-16 system lines up so neatly with binary and with byte boundaries.
Should I include the 0x prefix?
It depends on the context. In C, Rust, Go and most programming languages the 0x prefix is required so the compiler knows the literal is hexadecimal. In configuration files, logs and protocol headers the bare eight-digit form is usually written without a prefix. This page shows both.
How do I convert a decimal octet to hex by hand?
Divide by 16 and use the remainder. For 192: 192 ÷ 16 = 12 with remainder 0, and 12 is C in hex, so the digits are C and 0, giving C0. For 168: 168 ÷ 16 = 10 remainder 8, and 10 is A, giving A8. Values 10 to 15 map to A, B, C, D, E and F.
How do I convert hex back to an IP address?
Split the eight digits into four pairs, then convert each pair to decimal. For C0A80101: C0 is 12 × 16 + 0 = 192, A8 is 10 × 16 + 8 = 168, 01 is 1, and 01 is 1, giving 192.168.1.1. Use the hex to IP converter for the reverse direction.
Why do I sometimes see hex with dots or colons?
Dots or colons between pairs are a readability aid, not part of the value. C0.A8.01.01 and C0:A8:01:01 both mean C0A80101. Some vendor formats use this convention so a human can spot which byte is which without counting from the left.