1001Ferramentas
🔄Dev

IPv6 Shortener / Expander

Expand an IPv6 to its full form, or shorten using :: notation.

Forma completa

Forma curta

Canonical IPv6 address form under RFC 5952

The same IPv6 address can be written many ways, and that is where the problem starts: text comparison in access lists, logs and databases fails when two spellings name the same host. RFC 5952 exists to end that, fixing one canonical form. The page expands to the full eight groups and reduces to that form.

There are four rules and all are mandatory. Lowercase hexadecimal; leading zeros within each group removed; the longest run of zero groups replaced by a double colon, and never a run of a single group; and where two runs of equal length tie, the first is the one compressed. The tie rule is the one most often missing from home-grown implementations.

There is also mixed notation, required for IPv4-mapped addresses: the page writes the last 32 bits in dotted decimal when the address falls in the range beginning with a double colon followed by ffff. It is the form that shows up in logs from a server accepting both families, and the page accepts that format on input too, along with a zone after the percent sign and a prefix after the slash.

Frequently asked questions

Why not compress a single zero group?
Because the gain is nil — a double colon takes the same space as the zero it would replace — and the ambiguity is real: a reader cannot tell whether one group or several stood there. The standard forbids it so that the canonical form is genuinely unique, which is its whole point.
Is uppercase wrong?
It is not invalid, and any implementation accepts it on input. But the canonical form is lowercase, and that is what counts when writing to a database, into configuration or when comparing two strings. The standard chose lowercase because it was what most implementations already emitted.
Is the zone part of the address?
No. The zone identifier after the percent sign says which interface to reach a link-local address through, and it is context, not address. The page strips it before canonicalising, which is the correct behaviour — two identical addresses with different zones are the same address.

Related Tools