IPv6 Expand β Compress
Convert between expanded and compressed IPv6 notation
The IPv6 Expand/Compress tool converts IPv6 addresses between their full 8-group hexadecimal notation and the shortened :: compressed form. Enter an address like 2001:db8::1 to see its expanded form 2001:0db8:0000:0000:0000:0000:0000:0001, or paste a full-length address to get the shortest valid compressed representation per RFC 5952.
Understanding IPv6 Address Notation
IPv6 addresses are 128 bits long, which means writing them out in full requires 32 hexadecimal digits. To make that manageable, the digits are split into eight groups of four, separated by colons: 2001:0db8:0000:0000:0000:0000:0000:0001. But even with the grouping, typing and reading 39 characters for every address gets old fast, especially when most of those characters are zeros. That is why RFC 2373 introduced compression rules, and RFC 5952 later standardized the canonical short form.
Compression works in two ways. First, you can drop leading zeros within each group: 0db8 becomes db8, and 0000 becomes 0. Second, you can replace the longest consecutive sequence of all-zero groups with ::. So 2001:0db8:0000:0000:0000:0000:0000:0001 compresses to 2001:db8::1 -- a much more readable seven characters. The catch is that you can only use :: once per address, because if you used it twice, you would not know how many zero groups each :: represents.
These two forms are completely equivalent -- they represent the same 128-bit number and work identically in every networking context. The choice between them is about readability and system requirements. Configuration files and firewall rules typically use the compressed form for brevity. Database storage, SNMP systems, and some log analysis tools prefer the expanded form because its fixed 39-character width simplifies parsing. This tool lets you convert instantly between the two, and it always produces the correct canonical form per RFC 5952 so your addresses are consistent across all your documentation and configurations.
How to Expand or Compress an IPv6 Address
- Enter an IPv6 address in either compressed or expanded format
- Select Expand to produce the full 8-group notation with leading zeros, or Compress to produce the shortest valid representation
- View the converted result along with both forms displayed side by side for comparison
IPv6 Expansion and Compression Examples
| Compressed Form | Expanded Form |
|---|---|
::1 | 0000:0000:0000:0000:0000:0000:0000:0001 |
:: | 0000:0000:0000:0000:0000:0000:0000:0000 |
2001:db8::1 | 2001:0db8:0000:0000:0000:0000:0000:0001 |
2001:db8::ff00:42:8329 | 2001:0db8:0000:0000:0000:ff00:0042:8329 |
fe80::1 | fe80:0000:0000:0000:0000:0000:0000:0001 |
::ffff:c0a8:101 | 0000:0000:0000:0000:0000:ffff:c0a8:0101 |
2001:db8:85a3::8a2e:370:7334 | 2001:0db8:85a3:0000:0000:8a2e:0370:7334 |
ff02::1 | ff02:0000:0000:0000:0000:0000:0000:0001 |
Compression with Multiple Zero Runs
When an address contains multiple sequences of consecutive zero groups, only the longest run is replaced with ::. If runs are equal length, the leftmost is compressed per RFC 5952:
| Expanded Form | Correct Compression | Incorrect |
|---|---|---|
2001:0db8:0000:0000:0001:0000:0000:0001 | 2001:db8::1:0:0:1 | 2001:db8:0:0:1::1 |
2001:0000:0000:0001:0000:0000:0000:0001 | 2001:0:0:1::1 | 2001::1:0:0:0:1 |
0000:0000:0000:0001:0000:0000:0000:0001 | ::1:0:0:0:1 | 0:0:0:1::1 |
When to Use IPv6 Expand/Compress
- Configuration file standardization -- ensure all IPv6 addresses in firewall rules, DNS records, and router configs use the same notation style
- Address comparison and deduplication -- expand two addresses to full form to determine if
2001:db8::1and2001:0db8:0000:0000:0000:0000:0000:0001are the same address (they are) - BIND zone file preparation -- some DNS systems require expanded or specific notation for AAAA records and reverse zone delegation
- Learning IPv6 structure -- expand compressed addresses to see exactly which groups are zero and understand the full 128-bit address layout
- ACL and policy auditing -- normalize addresses to a canonical form before comparing security policies across devices that may store addresses differently
- Database normalization -- convert all addresses to the same format before inserting into a database to enable reliable lookups and deduplication
How IPv6 Address Compression Works
Expansion Algorithm
- If
::is present, count the existing groups on each side - Calculate missing groups:
8 - (left_groups + right_groups) - Replace
::with the calculated number of0000groups - Pad each group to exactly 4 hex digits with leading zeros
Example: expanding 2001:db8::ff00:42:8329
Left of :: β 2001:db8 (2 groups)
Right of :: β ff00:42:8329 (3 groups)
Missing β 8 - 2 - 3 = 3 (three 0000 groups)
Result β 2001:0db8:0000:0000:0000:ff00:0042:8329
Compression Algorithm
- Pad all groups to 4 hex digits and split into 8 groups
- Find the longest consecutive run of all-zero groups
- Replace that run with
::(leftmost wins if tied) - Strip leading zeros from each remaining group
- Result is the canonical compressed form per RFC 5952
RFC 5952 Canonical Format Rules
- Hex digits must be lowercase (
2001:db8, not2001:DB8) - Leading zeros must be suppressed (
db8, not0db8) - The longest run of consecutive
0groups must be compressed ::must not be used for a single0group (use0instead)
Practical Advice for IPv6 Notation
Consistency is the most important thing when choosing a notation style. Pick one form -- usually compressed for human-facing configurations and expanded for machine-parsed data -- and stick with it throughout your documentation, firewall rules, and configuration templates. Mixing 2001:db8::1 in one place and 2001:0db8:0000:0000:0000:0000:0000:0001 in another makes it harder to search, grep, and compare addresses across files.
When troubleshooting, the expanded form is your friend. If you are comparing two addresses and they look different in compressed form, expand both to full notation and compare group by group. This immediately reveals whether the addresses differ or are just written in different compression styles. It also makes it easier to identify which part of the address is the network prefix and which is the interface identifier, especially for non-standard prefix lengths like /48 or /56.
One subtle gotcha: some older tools and systems do not handle :: correctly, particularly when it appears at the beginning or end of the address. If you encounter a system that chokes on ::1 or fe80::, try the expanded form instead. This is increasingly rare as IPv6 support has matured, but you may still encounter it in embedded systems, legacy monitoring platforms, or custom scripts that use naive string parsing instead of proper address libraries.
Frequently Asked Questions
Are 2001:db8::1 and 2001:0db8:0000:0000:0000:0000:0000:0001 the same address?
Yes, they represent exactly the same 128-bit address. The expanded form shows all 32 hexadecimal digits explicitly, while the compressed form uses :: to omit consecutive zero groups and drops unnecessary leading zeros. Converting both to the same notation confirms equivalence.
Why do some systems require the expanded form?
Older network devices, certain SNMP implementations, and some log analysis tools expect a fixed 39-character address format. The expanded form with colons is always exactly 39 characters (xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx), which simplifies parsing in systems that use fixed-width field formats.
Does compression change the address value?
No. Compression is purely a notation change. The underlying 128-bit binary value remains identical. Expanding and then compressing an address always returns the original value, and both forms are interchangeable in any context that accepts IPv6 addresses.
Why does RFC 5952 require lowercase hex digits?
RFC 5952 standardizes the canonical representation to ensure consistency. While both 2001:DB8::1 and 2001:db8::1 are valid, having a single canonical form prevents duplicate entries in databases, simplifies string comparisons, and makes grep/search operations reliable. Lowercase was chosen as the canonical form.
Can I use this tool with IPv4-mapped IPv6 addresses?
Yes. An address like ::ffff:192.168.1.1 can be expanded to show the full notation. The mixed notation with an embedded IPv4 address is also supported, though the expanded form will display the IPv4 portion as two hexadecimal groups (e.g., ::ffff:c0a8:0101).
Related Tools
- IPv6 Validator - Validate IPv6 addresses (full and compressed formats)
- IPv6 β BigInt Converter - Convert IPv6 addresses to/from 128-bit integers
- IPv6 β Binary Converter - Convert IPv6 addresses to/from binary notation
- IPv4-Mapped IPv6 Converter - Convert between IPv4 and IPv4-mapped IPv6 (::ffff:)
- IPv4 Validator - Validate IPv4 addresses in strict dotted-quad format