IPv4 ↔ Integer

Convert IPv4 between dotted, integer, hex and binary.

Open tool

Overview

The IPv4 to integer converter switches an IPv4 address between four equivalent forms: dotted decimal (192.168.1.1), 32-bit integer (3232235777), hexadecimal (0xC0A80101), and binary (11000000.10101000.00000001.00000001). Paste any one and the other three populate automatically.

Database engineers storing IPs as integers, embedded developers packing addresses into 32-bit fields, and learners working through how dotted notation actually maps to bits all need a fast converter. Long-tail keywords covered: convert IPv4 to integer online, IPv4 to hex calculator, and IPv4 to binary representation.

How it works

An IPv4 address is a 32-bit unsigned integer. The dotted form simply splits those 32 bits into four 8-bit octets written in decimal and joined by dots. The integer form is the same 32 bits read as one number, almost always in big-endian (network byte order). The hex form is the same number in base 16, typically zero-padded to 8 digits.

Conversion is purely arithmetic: octet1 * 256³ + octet2 * 256² + octet3 * 256 + octet4 = integer. The hex form is the integer rewritten with printf("%08X", value). Some legacy systems store the integer in host byte order (little-endian), which flips the octets — watch for this when integrating with a database column or a binary log format.

Examples

  • 192.168.1.132322357770xC0A8010111000000.10101000.00000001.00000001.
  • 127.0.0.121307064330x7F000001.
  • 255.255.255.25542949672950xFFFFFFFF.
  • 0.0.0.000x00000000.

FAQ

Why store IPv4 as an integer?

A 4-byte column is half the size of a 15-character string, sorts and compares numerically, and indexes faster. Most relational databases offer this as a built-in type or via a function pair.

What about IPv6?

IPv6 is 128 bits, which exceeds a standard 64-bit integer. Store it as a 16-byte binary column or as a string, or use a database type designed for IPv6 (PostgreSQL's inet, for example).

Is the integer form signed or unsigned?

Always unsigned — 255.255.255.255 is 4294967295, which overflows a signed 32-bit integer. Some legacy systems silently use signed storage and flip the high bit, which is why you sometimes see negative values for high IPs.

Big-endian or little-endian?

Network byte order (big-endian) is the standard. If you read an integer out of memory on an x86 system and it looks reversed, you are seeing little-endian host order; htonl / ntohl convert between the two.

Try IPv4 ↔ Integer

An unhandled error has occurred. Reload ×