IP Address to Decimal Conversion

Converts an IPv4 address to a single decimal number and back. This is what you need when addresses are stored as integers or compared as ranges. Hexadecimal and binary forms are also shown.

This tool converts an IPv4 address into a single decimal number, and converts such a number back into an address. It is what you need when addresses are stored as integers or compared as ranges.

V=16777216a+65536b+256c+dV = 16777216 a + 65536 b + 256 c + d

Here aa to dd are the four octets and VV the decimal value. The coefficients are 2242^{24}, 2162^{16}, 282^{8} and 202^{0}, so the leading octet carries the most weight.

Why a single number is useful

An address is a 32-bit number to begin with, split into four groups of eight bits and joined by dots for legibility. Removing the dots simply returns it to an integer.

As an integer, comparisons and range tests are written with nothing more than inequalities. Left as text, 10.0.0.9 and 10.0.0.10 will not sort into the right order.

Worked example

The address 192.168.1.1 is 3232235777 in decimal and C0A80101 in hexadecimal.

192 × 16777216 = 3221225472, 168 × 65536 = 11010048 and 1 × 256 = 256; adding the final 1 gives 3232235777. In hexadecimal each octet occupies exactly two digits.

Points to watch

Only IPv4 is handled here. An IPv6 address is 128 bits and will not fit this form.

When converting from a decimal value, it must lie between 0 and 4294967295.