IPv4 to Integer Converter
Turn an IPv4 address into its 32-bit integer, hexadecimal and binary forms, or convert a decimal integer back to dotted-decimal.
How it works
integer = a × 256³ + b × 256² + c × 256 + d
Sources
- RFC 791 — Internet Protocol, DARPA Internet Program (1981)
- RFC 1918 — Address Allocation for Private Internets
- RFC 6890 — Special-Purpose IP Address Registries
Worked example: 192.168.1.1
Each octet is a base-256 digit. 192 × 16,777,216 = 3,221,225,472; 168 × 65,536 = 11,010,048; 1 × 256 = 256; plus the final 1. Adding those gives 3,232,235,777, which is the unsigned integer form of the address.
The hexadecimal form is 0xC0A80101 because 192 is C0, 168 is A8, 1 is 01 and 1 is 01 in hexadecimal. The binary form is 11000000.10101000.00000001.00000001 — each octet as eight bits. Entering the integer 3,232,235,777 returns the same address, so the conversion works in both directions.
How the conversion works
An IPv4 address is four bytes, and reading it as one number is positional notation with base 256. The first octet counts 256³ (16,777,216), the second 256² (65,536), the third 256 and the fourth 1. Summing them gives a value from 0 to 4,294,967,295, the range of an unsigned 32-bit integer.
The converter accepts either direction because both are unambiguous: a dot means dotted-decimal, no dot means an integer. Nothing is guessed, and an out-of-range number is rejected rather than wrapped.
When you need the integer form
Databases store addresses as 32-bit unsigned integers because a single indexed column sorts and range-queries far faster than four text fields. Subnet membership then becomes a comparison: an address belongs to a block when its integer falls between the block’s network and broadcast values.
It is also the form used in log analysis, CSV and spreadsheet joins, and any API that returns addresses as numbers. The reserved addresses fit the same scheme: 0.0.0.0 is integer 0 and 255.255.255.255 is 4,294,967,295, which is the largest possible unsigned 32-bit value. Hex turns up in packet captures and configuration dumps, where 0xC0A80101 is easier to compare against a bitmask than dotted-decimal.
Common mistakes
The most common failure is signed 32-bit overflow. Addresses above 127.255.255.255 are larger than 2,147,483,647, so languages with signed ints — Java and C among them — show 192.168.1.1 as a negative number unless the type is unsigned or a wider integer is used.
The second is leading zeros. Some languages read 192.168.001.001 as octal, silently producing a different address; this converter parses decimal only. The third is byte order: 0xC0A80101 is the natural big-endian reading, while the same four bytes stored on a little-endian machine appear as 01 01 A8 C0.
Finally, this tool is IPv4 only. An IPv6 address is 128 bits and does not fit in a 32-bit integer, so it needs a different representation entirely.
Questions
Why would I need an integer?
Databases store addresses as 32-bit integers because a single indexed number sorts and ranges far faster than a string, and it makes subnet containment a simple comparison.
Is this signed or unsigned?
Unsigned. Addresses above 127.255.255.255 would be negative if stored in a signed 32-bit integer, so the usual form is an unsigned 32-bit value.