IPv6 Compress / Expand
Convert IPv6 addresses between compressed and expanded forms.
An IPv6 address is 128 bits, written as eight groups of 16 bits separated by colons (e.g. 2001:0db8:0000:0000:0000:0000:0000:0001). A compressed form that omits zeros (2001:db8::1) is also common. This converter translates between the two forms, showing both the canonical compressed and the full expanded version no matter how you type it.
When the same address appears in different forms across firewall rules, logs and config files, normalize to the expanded form to compare them reliably. For IPv4 range math, pair this with the CIDR calculator.
| Compressed (canonical) | 2001:db8::1 |
|---|---|
| Expanded (full) | 2001:0db8:0000:0000:0000:0000:0000:0001 |
Compression rules
- Drop leading zeros in each group:
0db8→db8. - Replace only the longest run of all-zero groups with
::. If runs tie, the first one is compressed.
Common IPv6 addresses
::1— loopback (IPv4 127.0.0.1)::— unspecified address (all zeros)fe80::/10— link-local2001:db8::/32— documentation range
Expanded ↔ compressed reference table
The same address shown side by side in both forms, following RFC 5952 exactly (lowercase, a single zero group is never shortened to ::, and only the longest zero run is compressed).
| Expanded form | Compressed | Note |
|---|---|---|
2001:0db8:0000:0000:0000:0000:0000:0001 | 2001:db8::1 | Drop leading zeros + collapse zero run |
2001:0db8:0000:0000:0001:0000:0000:0001 | 2001:db8::1:0:0:1 | Two zero runs (length 2 + 2). On a tie, the first is compressed |
fe80:0000:0000:0000:0202:b3ff:fe1e:8329 | fe80::202:b3ff:fe1e:8329 | Link-local + EUI-64 |
2001:0db8:0000:0001:0000:0000:0000:0001 | 2001:db8:0:1::1 | The length-1 run stays as 0; only the length-3 run collapses |
0000:0000:0000:0000:0000:ffff:c000:0201 | ::ffff:192.0.2.1 | IPv4-mapped — last 32 bits stay dotted |
Finding the longest zero run — step by step
Walking through how 2001:0db8:0000:0000:0001:0000:0000:0000 compresses:
- Strip leading zeros per group:
2001 db8 0 0 1 0 0 0. - Locate zero runs: a length-2 run at groups 3–4 and a length-3 run at groups 6–8.
- The longest run is the length-3 one (at the end). Only it becomes
::→2001:db8:0:0:1::. - The earlier length-2 run stays as
0:0(collapsing both would make the address unrecoverable).
Result: 2001:db8:0:0:1:: (expanded: 2001:0db8:0000:0000:0001:0000:0000:0000).
Common pitfall
- Shortening a single zero group, e.g. writing
2001:db8:0:1::1as2001:db8::1::1— RFC 5952 forbids using::for a lone zero group, so keep it as0even though it is longer. - Using
::twice —2001::25de::cadeis invalid because the number of zero groups is ambiguous. - Confusing the address colon with a port — in a URL the address must be bracketed, e.g.
[2001:db8::1]:443, so the trailing colon reads as the port.