Expand / Collapse IPv6 Addresses
Switch an IPv6 address between its full and shortened form. Both forms are produced at once as you type, and CIDR notation is preserved.
How IPv6 compression works
A full IPv6 address is eight groups of four hexadecimal digits. RFC 5952 defines two shortenings that together produce the canonical short form:
-
Leading zeros inside each group are dropped:
2001:0db8becomes2001:db8. -
The longest run of all-zero groups is replaced with
::. This may happen only once per address, otherwise the address would be ambiguous. If two runs are the same length, the leftmost one is compressed. -
A run of a single zero group is written as
0, not::.
So 2001:0db8:0000:0000:0000:0000:0000:0001 collapses to
2001:db8::1, while 2001:db8:0:0:1:0:0:1 collapses to
2001:db8::1:0:0:1, keeping the second zero run written out.
Why it matters
The same address can be written many ways, so string comparison is unreliable. Logs, allowlists and access rules should normalise IPv6 to one canonical form first, or compare the underlying 128-bit value instead. The reverse DNS name shown above is derived from the expanded form for exactly that reason: every nibble has to be present.