IPv4 to Integer Converter

An IPv4 address is a 32-bit number written as four bytes. Its integer value is a × 256³ + b × 256² + c × 256 + d, which is how databases and range lookups often store it.

Also called: IP to decimal converter · IP address to long converter

  • Last updated
  • Formula tested against reference values

Your numbers

Convert

Result

Result
—

Calculating…

Unsigned 32-bit integer
—
Dotted-quad address
—
Hexadecimal
—
Binary (by octet)
—

How to use this calculator

  1. Enter or choose convert.
  2. The result updates as you type. Use Copy result or Share to keep it.

Method

Integer = a × 16,777,216 + b × 65,536 + c × 256 + d; a = ⌊n ÷ 2²⁴⌋ mod 256, b = ⌊n ÷ 2¹⁶⌋ mod 256, c = ⌊n ÷ 2⁸⌋ mod 256, d = n mod 256

a.b.c.d
the four octets, each 0–255
n
the integer, 0 to 4,294,967,295

Worked example

  1. 192 × 16,777,216 = 3,221,225,472; 168 × 65,536 = 11,010,048.
  2. 1 × 256 = 256 and the last octet is 1.
  3. Sum = 3,232,235,777 = 0xC0A80101.

192.168.1.1 is the integer 3,232,235,777, or 0xC0A80101 in hex.

What the result means

Storing addresses as unsigned integers makes range checks simple: an address is in a block if its integer lies between the block’s first and last address.

Assumptions and limits

  • Octets are written in decimal; leading zeros are rejected because some software reads them as octal.
  • Signed 32-bit integer columns cannot hold addresses from 128.0.0.0 upwards; use an unsigned or 64-bit type.

Questions

Why do some tools show a negative number?

They store the value as a signed 32-bit integer. Add 4,294,967,296 to a negative value to get the unsigned form shown here.

Does this work for IPv6?

No. IPv6 addresses are 128-bit; use the IPv6 Address Compression Calculator for their text forms.