IPv4 Address Converter: Convert IP Addresses Between Decimal, Binary, and Hex
Convert IPv4 addresses between dotted decimal, binary, hexadecimal, and 32-bit integer formats for networking courses, firewall config, and packet analysis.
Try the free online tool
Runs entirely in your browser — no signup, no uploads.
An IPv4 address is fundamentally a 32-bit binary number. The familiar dotted-decimal format (192.168.1.1) is simply a human-readable representation of those 32 bits, grouped into four 8-bit octets and expressed in base 10. But networking systems, packet headers, low-level APIs, firewall engines, and microcontrollers often work with IP addresses in binary, hexadecimal, or unsigned 32-bit integer form. Our IPv4 Address Converter instantly translates any IP address between all four representations — dotted decimal, binary, hexadecimal, and 32-bit integer — in a single step.
The need for IP address format conversion arises in more contexts than you might expect. Students studying for CCNA or CompTIA Network+ must be comfortable reading and converting binary octets to apply subnet masks and understand routing decisions. Developers writing packet parsers, raw socket programs, or pcap analysis tools encounter IP addresses as 4-byte big-endian integers in packet headers. Database administrators storing IP addresses as integers for fast range queries need to convert between the human-readable form and its numeric equivalent. Security engineers analyzing firewall logs or SIEM alerts often see hex-encoded IPs that must be decoded.
This guide explains the mathematical relationship between each IP address representation, demonstrates the conversion process step by step, and covers practical scenarios where each format is encountered. Whether you are debugging a network program, studying subnetting, or analyzing a packet capture, understanding IP address format conversion is a skill that pays dividends throughout your networking and development career.
What Is an IPv4 Address and How Is It Structured?
An IPv4 address is a 32-bit unsigned integer used to identify a host on an IP network. It is organized into four groups of 8 bits (octets), and each octet can represent a value from 0 (00000000 in binary) to 255 (11111111 in binary). The dotted-decimal notation writes each octet as a decimal number separated by dots: for example, the binary value 11000000.10101000.00000001.00000001 is written as 192.168.1.1 in dotted decimal. This format was chosen because it is easier for humans to read and remember than 32 consecutive binary digits.
The same 32-bit value can be expressed in other number bases without any loss of information. In hexadecimal (base 16), each octet becomes exactly two hex digits, producing a compact 8-character representation like C0A80101 for 192.168.1.1. In binary, all 32 bits are written out explicitly: 11000000101010000000000100000001. As a 32-bit unsigned integer, the address is simply its numeric value: 192.168.1.1 equals 3,232,235,777 in decimal. All four forms represent the same underlying address — they are simply different bases for expressing the same 32-bit quantity.
Understanding this structure is critical for subnetting, routing, and security analysis. When a router applies a subnet mask, it performs a bitwise AND between the IP address and the mask, both in binary. Seeing an IP in binary makes the network and host portions visually obvious. When working with Berkeley socket APIs or parsing pcap files, IP addresses arrive as 4-byte values in network byte order (big-endian), which is most naturally expressed as a hex string. The converter bridges these representations, letting you move fluidly between whatever format a tool or specification provides and whatever format you need to work with.
How to Use This Tool
The IPv4 Address Converter accepts input in any of the four supported formats and immediately outputs all other representations. No format selection is required — the tool detects your input automatically.
- 1
Enter the IP Address in Any Format
Type or paste your IPv4 address in any supported format: dotted decimal (192.168.1.1), 32-bit binary (11000000101010000000000100000001), hexadecimal (C0A80101 or 0xC0A80101), or a 32-bit unsigned integer (3232235777). The tool auto-detects the input format based on the characters and structure you provide.
- 2
Review All Four Representations
The converter instantly displays the address in all four formats simultaneously. Each representation is clearly labeled so you can verify the conversion is correct. Binary output is formatted as four 8-bit groups for readability, and hex output is shown both with and without the 0x prefix.
- 3
Examine Per-Octet Breakdown
The detailed breakdown shows each of the four octets individually in decimal, binary, and hex. This is especially useful for studying subnetting, where you need to understand which bits fall in the network portion and which are host bits, and for verifying manual binary-to-decimal conversions during exam preparation.
- 4
Use Specific Formats as Needed
Copy the format you need for your specific task: the binary representation for subnetting study, the hex string for packet analysis or socket programming, the integer for database storage or firewall API calls, or the dotted decimal for human-readable configuration files and documentation.
- 5
Convert Multiple Addresses in Sequence
Clear the input and enter a new address to convert additional IPs. When working through a list of addresses — analyzing a log file, building a test dataset, or verifying a range of firewall rules — quickly convert each address in sequence and copy the needed representation for each.
Common Use Cases
IP address format conversion is needed across networking, development, security, and education. These are six of the most common real-world scenarios where the converter provides direct value.
- Subnetting Study and Certification Prep: CCNA and Network+ exams require you to manually convert IP addresses and subnet masks to binary to determine network boundaries, compute host ranges, and verify VLSM designs. The converter lets you check your manual binary conversions instantly and builds intuition for reading IP addresses in binary.
- Packet Analysis with Wireshark or tcpdump: IP headers in packet captures encode addresses as 4-byte big-endian values. When examining raw hex dumps in Wireshark's hex pane or a hex editor, you see the IP addresses as hex strings (e.g., C0A80101). The converter translates these to dotted decimal so you can identify source and destination addresses.
- Firewall and WAF API Configuration: Some firewall APIs, Web Application Firewall (WAF) rules engines, and low-level network configuration tools accept IP addresses as 32-bit integers rather than dotted-decimal strings. Converting 192.168.0.0 to 3232235520 before submitting an API call is a common developer task that this tool handles instantly.
- Database IP Storage Optimization: Storing IP addresses as unsigned 32-bit integers in a relational database (INET_ATON/INET_NTOA in MySQL, or manual conversion in PostgreSQL) allows efficient range queries and indexing. The converter confirms the integer value for a given dotted-decimal address before writing database migration scripts or seed data.
- Low-Level Network Programming: Socket APIs in C, Go, and other systems languages accept IP addresses as binary structures (in_addr, sockaddr_in). When debugging, the hex representation of an address in a memory dump must be converted to dotted decimal to understand which host is being addressed. The converter bridges this gap during debugging sessions.
- Security Log and SIEM Analysis: Security information and event management (SIEM) systems and intrusion detection tools sometimes log IP addresses in hex or integer format, especially when ingesting data from network devices. The converter decodes these representations during threat hunting or incident response to identify involved hosts.
Key Concepts Explained
The conversion between dotted decimal and binary is performed one octet at a time. Each octet is an 8-bit unsigned integer. To convert decimal 192 to binary: 192 = 128 + 64 = 2^7 + 2^6, so the binary representation is 11000000. To convert 168: 168 = 128 + 32 + 8 = 2^7 + 2^5 + 2^3 = 10101000. Each octet always produces exactly 8 binary digits — pad with leading zeros if needed (e.g., decimal 1 = 00000001 in binary). Concatenate all four binary octets to get the full 32-bit binary representation.
Hexadecimal conversion takes the binary representation and groups bits into nibbles (4 bits each). Since each hex digit represents exactly 4 bits, an 8-bit octet maps to exactly two hex digits. The mapping is: 0000=0, 0001=1, …, 1001=9, 1010=A, 1011=B, 1100=C, 1101=D, 1110=E, 1111=F. For octet 192 (11000000 in binary): split into 1100 (C) and 0000 (0) = C0. For octet 168 (10101000): 1010 (A) and 1000 (8) = A8. The full 32-bit hex for 192.168.1.1 is C0A80101.
The 32-bit integer representation treats the entire IP address as a single unsigned 32-bit number in network byte order (big-endian, most significant byte first). To compute it: multiply the first octet by 2^24 (16777216), the second by 2^16 (65536), the third by 2^8 (256), and add the fourth directly. For 192.168.1.1: (192 × 16777216) + (168 × 65536) + (1 × 256) + 1 = 3221225472 + 11010048 + 256 + 1 = 3232235777. This integer is what network byte order represents in packet headers, and the socket function htonl() converts from host to network byte order on little-endian systems.
Tips and Best Practices
Apply these practical tips when working with IP address format conversion to avoid common mistakes in networking and development contexts.
- Always verify octet ranges: each octet in dotted decimal must be between 0 and 255. Values like 192.168.300.1 are invalid — 300 exceeds 8 bits. When generating IP addresses programmatically, validate each octet before formatting or converting to prevent downstream errors in routing or firewall rules.
- Be aware of byte order when working with integers: 32-bit integer IP representations are in network byte order (big-endian). On x86/x64 systems (little-endian), you must call htonl() before using an integer IP in a socket structure, or you will connect to the wrong host. The converter always shows the standard network-byte-order integer value.
- Pad binary octets to 8 digits: when manually writing or interpreting binary IP addresses, always pad each octet to exactly 8 digits with leading zeros. Writing 1.1.1.1 as 1.1.1.1 in binary might become 1.1.1.1 instead of 00000001.00000001.00000001.00000001, which causes errors in subnet mask application.
- Use hex representation for packet header analysis: when examining IP packets in a hex dump, recognize that a 4-byte sequence like C0 A8 01 01 is an IP address. Knowing that network addresses always appear in a predictable location within IP headers (bytes 12–15 for source, 16–19 for destination) makes identifying them in raw hex fast and reliable.
- For database storage, use the platform's built-in functions: MySQL provides INET_ATON() and INET_NTOA() for conversion; PostgreSQL has the inet type with built-in operators. Use these over manual conversion in application code to ensure correctness, handle edge cases (like loopback and broadcast addresses), and take advantage of indexed range queries.
IPv4 Address Conversion in Network Programming
Network programmers encounter IP address format conversion constantly when working with raw sockets, packet crafting, or network protocol implementations. In C, the POSIX functions inet_pton() and inet_ntop() convert between text presentation (dotted decimal) and binary network format (the in_addr struct, which is a 32-bit big-endian integer). The older inet_addr() and inet_ntoa() functions are deprecated because they are not thread-safe and do not support IPv6.
In Python, the ipaddress module (standard library since Python 3.3) provides an IPv4Address class that handles all format conversions. You can access the packed 4-byte big-endian representation via the packed attribute, the integer representation via int(addr), and convert back from an integer with IPv4Address(int_value). The socket module's inet_aton() and inet_ntoa() functions provide similar functionality for interoperability with C-style network code.
In Go, the net package's net.IP type is a byte slice that can be converted to a 4-byte or 16-byte representation. The net.ParseIP() function accepts dotted-decimal strings, while encoding/binary.BigEndian.Uint32() converts the 4-byte slice to a uint32. JavaScript developers working with Node.js use similar approaches through the built-in net module or libraries like ip-address. Understanding what each function produces and expects — text, binary slice, or integer — prevents subtle bugs in network applications that may only manifest when handling specific address ranges.
Frequently Asked Questions
Why would anyone store an IP address as a 32-bit integer?
Integer storage is significantly more efficient for database IP range queries. A WHERE clause comparing integers (ip_int BETWEEN 3232235520 AND 3232235775) uses an index and runs in microseconds, while string comparison with LIKE '192.168.%' is slow and imprecise. MySQL's INET_ATON() / INET_NTOA() functions are specifically designed for this pattern, and it is standard practice in high-performance logging, analytics, and geolocation databases.
Is the 32-bit integer representation the same as what appears in a packet header?
Yes, exactly. An IPv4 packet header stores source and destination addresses as 32-bit values in network byte order (big-endian), which is the same byte ordering used by the integer representation. On a big-endian system there is no conversion needed; on little-endian x86/x64 systems, use htonl() (host-to-network long) to convert before writing to the socket structure and ntohl() (network-to-host long) to convert after reading.
What does 0.0.0.0 mean as an IP address?
0.0.0.0 is the all-zeros address, which has several context-dependent meanings. In server socket binding, it means "listen on all available interfaces." In routing tables, it represents the default route (0.0.0.0/0 — all destinations). In DHCP, a client uses 0.0.0.0 as its source address before it has obtained an IP. As a 32-bit integer, it is simply 0.
How do I convert a hex string like C0A80101 back to dotted decimal?
Split the 8-character hex string into four 2-character pairs: C0, A8, 01, 01. Convert each pair from hex to decimal: C0 = 192, A8 = 168, 01 = 1, 01 = 1. Assemble as dotted decimal: 192.168.1.1. This is exactly what the converter does automatically — enter the hex string and the dotted decimal result is shown instantly.
What is the highest valid IPv4 address?
The highest IPv4 address is 255.255.255.255, which in binary is all 32 bits set to 1, in hex is FFFFFFFF, and as a 32-bit unsigned integer is 4,294,967,295 (2^32 - 1). This address is the limited broadcast address — sending to it delivers to all hosts on the local network segment. It is not routable across the internet.
Why do some IP addresses show as hex in Wireshark?
Wireshark decodes IP addresses into dotted decimal in the protocol tree view, but the raw hex pane shows the actual bytes of the packet. In the hex pane, IP addresses appear as their 4-byte binary values, which are conventionally displayed as hexadecimal. A source address of 192.168.1.100 appears as C0 A8 01 64 in the hex dump — each byte is one octet of the IP address.
Is there a difference between IPv4 decimal and IPv4 long notation?
"IPv4 long" typically refers to the 32-bit integer representation, as opposed to the standard dotted-decimal notation (sometimes called "IPv4 dotted" or just "IPv4 decimal"). They are the same address expressed differently: 192.168.1.1 (dotted) versus 3232235777 (long integer). Some older APIs and configuration files use the long notation; the converter handles both.
Can I enter a hex IP with the 0x prefix into the converter?
Yes, the converter accepts hexadecimal input both with and without the 0x prefix. Entering 0xC0A80101 or C0A80101 produces the same result: 192.168.1.1 in dotted decimal. The tool also accepts space-separated or colon-separated hex octet pairs (C0:A8:01:01) as an alternative input format for convenience.
Ready to use this tool?
Free, instant, no account required. Runs entirely in your browser.