RunTheTests
/

IPv6 Expand / Compress

Expand an IPv6 address to all eight groups, or compress it back correctly.

What you provide

Either form. Compressed addresses use :: for a run of zero groups.

Result

2001:db8::1

The two forms are the same address. Compression follows RFC 5952: "::" replaces the longest run of zero groups, appears at most once, and is not used for a single zero group — that last rule exists because shortening one group saves nothing and makes the address harder to read back correctly. Leading zeros inside a group are always dropped.

Diagnostic telemetry
Expanded
2001:0db8:0000:0000:0000:0000:0000:0001
Compressed
2001:db8::1
Groups
2001 · 0db8 · 0000 · 0000 · 0000 · 0000 · 0000 · 0001

What this cannot tell you

  • Converts between notations for the same address. It does not check whether the address is assigned, routable or reachable.
  • Compression follows RFC 5952: the longest run of zero groups is replaced, :: appears at most once, and a single zero group is never compressed.
  • Runs entirely in your browser. Nothing is looked up, transmitted or stored.

Take this with you

How this calculation works

An IPv6 address has eight groups of four hex digits, and two shortenings are permitted: leading zeros inside a group are dropped, and one run of all-zero groups may be replaced by a double colon. Expanding restores both. Compressing back is where implementations differ, and RFC 5952 settles it: replace the longest run of zeros rather than the first, never use :: more than once, and never compress a single zero group — that last rule exists because shortening one group saves nothing and makes the address harder to read back correctly. A trailing IPv4 form is handled too, since it is legal and becomes two hextets.

What the results mean

Expanded
All eight groups, four digits each. What you want when comparing addresses by eye or pasting into something strict.
Compressed
The canonical short form under RFC 5952.
::
Stands for one or more all-zero groups. Legal only once in an address.
Groups
The eight hextets separately, for checking a specific position.

Common problems and fixes

It rejects my address with two double colons
Only one :: is allowed. With two, the number of zero groups each stands for is ambiguous, so the address has no single meaning.
The compressed form differs from what I had
Yours may have compressed the first zero run rather than the longest, or compressed a single group. Both are valid to parse and neither is canonical.
My address ends in an IPv4 address
That form is legal and is expanded into the final two hextets. It appears in IPv4-mapped addresses.

Frequently asked questions

Why can :: only appear once?

Because it stands for a variable number of zero groups. With two, there is no way to know how many belong to each, so the address would have several possible expansions.

Why is a single zero group not compressed?

RFC 5952 forbids it because it saves no characters and makes the address harder to read back. Writing 2001:db8:0:1:: rather than 2001:db8::1:: avoids that ambiguity.

Are the two forms the same address?

Yes, exactly. Compression is purely notational — nothing about the address changes.

Put this on your own site

Free to embed, no attribution required beyond the source link the frame carries itself. It runs entirely in your visitor's browser, sets no cookies and loads no third-party script.

Embed code
<iframe src="https://runthetests.com/embed/ipv6-expand/" width="100%" height="560" style="border:1px solid #e5e5e5;border-radius:8px" title="IPv6 Expand / Compress" loading="lazy"></iframe>

Preview it at https://runthetests.com/embed/ipv6-expand/. Embedded pages are marked noindex, so yours stays the canonical copy — not this one.

More in NetMath