IP Address Converter
Convert IPv4 between decimal, binary, hex, integer, and IPv4-mapped IPv6
Accepts: dotted decimal, binary octets, hex octets, compact hex (0x…), 32-bit integer, or IPv4-mapped IPv6
Enter an IPv4 address in any format — dotted decimal, binary, hex, or integer — to get all representations simultaneously. Useful for networking, packet analysis, and database IP storage.
You’re reading a firewall rule that stores IPs as 32-bit integers, or you need to verify a binary subnet mask, or you want to know the hex representation for a network packet header. Enter an IP address in any format and get all representations instantly.
IPv4 Address Formats
An IPv4 address is fundamentally a 32-bit unsigned integer. The dotted decimal notation (192.168.1.1) is just the most human-readable representation of those 32 bits. The same address can be expressed as:
| Format | Example (192.168.1.1) |
|---|---|
| Dotted decimal | 192.168.1.1 |
| Binary (octets) | 11000000.10101000.00000001.00000001 |
| Hexadecimal | C0.A8.01.01 or 0xC0A80101 |
| 32-bit integer | 3232235777 |
| IPv4-mapped IPv6 | ::ffff:192.168.1.1 |
Why These Formats Matter
Binary: Critical for understanding subnet masks and CIDR notation. The subnet mask 255.255.255.0 in binary is 11111111.11111111.11111111.00000000, which shows exactly which bits identify the network vs the host.
Hexadecimal: Widely used in network packet captures (Wireshark), kernel routing tables, C/C++ socket programming, and IPv6 representations. The hex form of an IP address appears directly in packet headers.
32-bit integer: Used in database columns (MySQL INET_ATON() and INET_NTOA()), some firewall APIs, and anywhere IPs need to be sorted numerically.
IPv4-mapped IPv6: The ::ffff:0:0/96 range is used in dual-stack networks where an IPv6-only socket receives an IPv4 connection. The client’s address appears as ::ffff:192.168.1.1.
Converting IPv4 in Code
JavaScript
function ipToInt(ip) {
return ip.split('.').reduce((acc, oct) => (acc << 8) | parseInt(oct, 10), 0) >>> 0;
}
function intToIp(int) {
return [(int >>> 24) & 0xFF, (int >>> 16) & 0xFF, (int >>> 8) & 0xFF, int & 0xFF].join('.');
}
function ipToHex(ip) {
return '0x' + ipToInt(ip).toString(16).padStart(8, '0').toUpperCase();
}
Python
import socket, struct
def ip_to_int(ip):
return struct.unpack('!I', socket.inet_aton(ip))[0]
def int_to_ip(n):
return socket.inet_ntoa(struct.pack('!I', n))
def ip_to_hex(ip):
return hex(ip_to_int(ip)) # e.g. '0xc0a80101'
MySQL
SELECT INET_ATON('192.168.1.1'); -- returns 3232235777
SELECT INET_NTOA(3232235777); -- returns '192.168.1.1'
Frequently Asked Questions
What is the maximum IPv4 address? 255.255.255.255, which equals 4,294,967,295 in decimal and 0xFFFFFFFF in hex. This is the broadcast address for the global network and a 32-bit unsigned integer at its maximum value.
Why is 192.168.1.1 equal to 3232235777? 192×2²⁴ + 168×2¹⁶ + 1×2⁸ + 1 = 3221225472 + 11010048 + 256 + 1 = 3232235777.
What does ::ffff prefix mean in IPv4-mapped IPv6?
::ffff:0:0/96 is the IPv4-mapped IPv6 address range defined in RFC 4291. The ::ffff: prefix marks the address as an IPv4 address embedded in IPv6 form. This is used by dual-stack TCP/IP implementations.
Can I enter a 32-bit integer to convert to dotted decimal? Yes. Enter the integer in the input field — the tool detects that it is a plain number and converts it to all other formats.