How to Use This Tool
Paste an address in any valid form. You get the fully expanded version and the RFC 5952 canonical version, plus a list of which rule caused each change.
Why “valid” is not enough
IPv6 lets you write the same 128 bits many ways. 2001:DB8:0:0:0:0:0:1,
2001:db8:0:0::1 and 2001:db8::1 are one address and three strings.
That is fine until something compares them as text — and text comparison is everywhere:
allow-lists, grep over logs, a unique index on a varchar column, a cache key, a rate-limit
bucket. Two systems that both shorten “correctly” but differently will disagree, and the
failure looks like an intermittent access bug rather than a formatting one.
RFC 5952 fixes that by defining one canonical text form. Four rules do the work:
- Leading zeros are dropped.
0db8becomesdb8,0000becomes0. - Hex is lowercase.
DB8becomesdb8. ::replaces the longest run of zero groups — and on a tie, the leftmost of them.::is never used for a single zero group.
The two rules tools get wrong
Rule 3 produces results that look unfinished. 2001:db8:0:0:1:0:0:1 has a run of two
zeros and then another run of two zeros — a tie, so the leftmost wins and the canonical form is
2001:db8::1:0:0:1. But in 2001:db8:0:0:1:0:0:0 the second run is
longer, so the canonical form is 2001:db8:0:0:1::, which still has two visible zeros in it.
That looks like a job half done, and it is correct.
Rule 4 is the one almost every online compressor violates. 2001:db8:0:1:1:1:1:1 has a
single zero group. Replacing it gives 2001:db8::1:1:1:1:1, which is one character shorter
and not canonical. The rule exists because :: standing for exactly one
group carries no information and creates two spellings where one would do.
What this does not do
Zone identifiers (%eth0) and prefix lengths (/64) are accepted and passed
through unchanged, but not validated — a zone ID is a local interface name and there is nothing
to check it against. Embedded IPv4 in the last 32 bits is recognised and reported, but the canonical
output keeps the dotted form only for addresses where RFC 5952 says it belongs.
