๐ข IPv4 Address โ Integer Converter
Converts between an IPv4 address (e.g. 192.168.1.1) and its corresponding 32-bit unsigned integer, hexadecimal, and binary representations. Handy for checking IP-address-as-integer conversions used in databases.
How to use
- Choose the "IP to Integer" or "Integer to IP" tab.
- Enter an IPv4 address or an integer value.
- The corresponding IP address, integer, hex, and binary representations are all shown together.
How the calculation works
An IPv4 address is really a single 32-bit number; "192.168.1.1" is that number split into four 8-bit parts written in decimal. This tool converts between that notation and the 32-bit integer, binary and hex forms. To get the integer, multiply by 256 and add, part by part: a.b.c.d = a ร 256ยณ + b ร 256ยฒ + c ร 256 + d JavaScript bitwise operators work on signed 32-bit values, so addresses starting at 128 or above would come out negative. This tool uses ordinary multiplication and division, so the whole range 0โ4,294,967,295 is handled correctly.
Worked example
192.168.1.1 Integer: 192 ร 16,777,216 + 168 ร 65,536 + 1 ร 256 + 1 = 3,232,235,777 Binary: 11000000.10101000.00000001.00000001 Hex: 0xC0A80101 And back: 3,232,235,777 โ 192.168.1.1 255.255.255.255 = 4,294,967,295 (the largest 32-bit value)
Things to be aware of
- Storing IP addresses as integers in a database lets you do range checks (is it in this network?) with numeric comparisons.
- Avoid leading zeros such as 192.168.001.001; some software reads them as octal.
- IPv6 addresses are 128 bits, so this conversion is for IPv4 only.
FAQ
How is the integer calculated?
Each octet of the address (a.b.c.d) is treated as a base-256 digit: aร256ยณ + bร256ยฒ + cร256 + d.
What's the min/max value?
IPv4 addresses are 32 bits, so the integer ranges from 0 (0.0.0.0) to 4294967295 (255.255.255.255).
Does this support IPv6?
No, this tool only supports IPv4 addresses.