IPv6 expander & compressor

What is an Ipv6 Expander Compressor?

IPv6 addresses are 128 bits long, written as eight groups of four hexadecimal digits. Because they are long, IPv6 allows a shortened form, but the same address can then be written several different ways. That makes comparing addresses in logs, configs and databases error-prone. This tool expands any IPv6 address to its full form or compresses it to the canonical short form defined in RFC 5952.

How to use it

  1. Paste an IPv6 address in any valid form.
  2. Read the fully expanded and the compressed versions.

Example

  • Expanded: 2001:0db8:0000:0000:0000:ff00:0042:8329
  • Compressed: 2001:db8::ff00:42:8329

Compression rules (RFC 5952)

  1. Remove leading zeros in each group: 0db8 becomes db8, 0042 becomes 42.
  2. Replace the longest run of consecutive all-zero groups with ::. If two runs are equally long, compress the first one.
  3. Do not use :: for a single zero group; write 0.
  4. :: may appear only once in an address, otherwise it would be ambiguous.
  5. Use lowercase hexadecimal letters.

More examples

  • Loopback: 0000:0000:0000:0000:0000:0000:0000:0001 compresses to ::1.
  • Unspecified address: all zeros compresses to ::.
  • 2001:db8:0:1:0:0:0:1 compresses to 2001:db8:0:1::1, because the run of three zero groups is longer than the single one.

When to use which

Use the compressed form for display, documentation and configuration. Use the expanded form when you need fixed-width strings, for example for sorting as text or for reverse DNS entries in ip6.arpa.

Frequently Asked Questions

How do I shorten an IPv6 address?

Remove leading zeros in each group and replace the longest run of all-zero groups with a double colon.

Can :: appear twice in an address?

No. It may appear only once, otherwise the number of zero groups it represents would be ambiguous.

What is the canonical IPv6 format?

The format defined by RFC 5952: lowercase, no leading zeros and the longest zero run compressed with a double colon.

What is ::1?

The IPv6 loopback address, the equivalent of 127.0.0.1 in IPv4.