IPv6 Address Compressor & Expander
Compress any IPv6 address to its RFC 5952 canonical form, or expand a compressed address back to all 8 groups — including addresses with an embedded IPv4 tail.
How to use this tool
- Paste any IPv6 address in any form — already compressed, fully expanded, uppercase, mixed — and both the canonical compressed form and the full 8-group expanded form appear at once.
- Use the preset buttons to see the specific rules in action: the tie-break case shows the leftmost run winning, the longest-run case shows a longer run beating an earlier shorter one.
- An IPv4-mapped address (the
::ffff:0:0/96range) is automatically shown with its trailing 32 bits as dotted-decimal, per RFC 5952. - Invalid input — too many groups, a bad hex digit, more than one
::— is flagged with a specific reason rather than a generic error. - Copy whichever form you need directly into a config file, firewall rule or DNS record.
An IPv6 address is 128 bits, written as eight 16-bit groups in hexadecimal, separated by colons. Because that is a lot to type and read, RFC 5952 defines a single canonical compressed form so that the same address always renders the same way — useful for log matching, access-control lists, and anywhere two addresses get compared as text instead of as numbers.
Compression has three rules, applied in order. First, every group is written in lowercase hex with no leading zeros, so 00FF becomes ff and 0042 becomes 42. Second, the single longest run of consecutive all-zero groups is replaced with ::, but only if that run is at least two groups long — a lone zero group is left as a bare 0, not compressed. Third, if two runs of zero groups tie for longest, the leftmost one is compressed and the other is left as literal zeros; this tie-break rule is what makes the canonical form unique instead of ambiguous.
:: can appear at most once in a valid address, because if it appeared twice the number of zero groups it represents would be ambiguous — the parser would have no way to know how many groups belong to the first gap versus the second. That is also why expansion has to reject any address containing :: twice, along with the more obvious errors like too many or too few groups, or a group with more than four hex digits.
Embedded IPv4 is a special case worth knowing about on its own. An IPv6 address can end in a dotted-decimal IPv4 literal instead of the last two hex groups, most commonly for IPv4-mapped addresses in the ::ffff:0:0/96 range, written like ::ffff:192.0.2.1. RFC 5952 recommends keeping that trailing IPv4 notation for addresses in this specific range rather than converting it to hex, since it makes the embedded IPv4 address immediately readable. The older IPv4-compatible form (a bare ::a.b.c.d with no ffff) is deprecated and this tool does not generate it, though it will still expand one correctly if you paste it in.
Two addresses that look completely different as text can be the same address: 2001:DB8::1, 2001:0db8:0000:0000:0000:0000:0000:0001 and 2001:db8::0:1 are all identical once normalized. That is exactly the problem RFC 5952 solves — text comparison, deduplication and log correlation all become reliable once every tool agrees on one canonical rendering for a given address.
Frequently asked questions
Why does 2001:0db8:0000:0000:0000:ff00:0042:8329 compress to 2001:db8::ff00:42:8329?
The three consecutive all-zero groups compress to ::, and the remaining groups drop their leading zeros: 0db8 becomes db8, 0042 becomes 42. This is the exact example RFC 5952 uses to illustrate canonical compression.
Why is a single zero group not compressed?
Because :: must represent at least two consecutive zero groups to be worth using. Compressing one lone zero group, like the middle group in 1:0:1:0:1:0:1:0, would save nothing and RFC 5952 explicitly forbids it — the canonical form for that address keeps every group written out.
What happens when two zero-runs are the same length?
The leftmost one gets compressed. For 1:0:0:1:0:0:1:1, both runs are two groups long, so the canonical form is 1::1:0:0:1:1 — the first run becomes :: and the second stays as literal zeros. This tie-break is what keeps the canonical mapping one-to-one.
Can :: appear more than once in an address?
No. A second :: would make the number of implied zero groups ambiguous, so it is invalid syntax, not just non-canonical. This tool rejects any input containing :: twice with an explicit error rather than guessing.
How is an IPv4-mapped address like ::ffff:192.0.2.1 handled?
It expands to the full 8-group hex form internally (0000:0000:0000:0000:0000:ffff:c000:0201 for that example), but when compressing back, RFC 5952 recommends showing the last 32 bits as dotted-decimal for addresses in the ::ffff:0:0/96 range specifically, which is what this tool’s compressed output does.
Related tools
- IPv6 subnet calculator: split a /48 into /64s
- Reverse DNS lookup: PTR for an IPv6 address