IPv6 Compress and Expand

Compress an IPv6 address to its shortest standard form, or expand it to all 32 hex digits. Paste one address or a whole list, one per line.

Updated
Converted in your browser. No address is looked up online.
Output

How to use the IPv6 Compress and Expand tool

  1. Paste addresses into IPv6 addresses, one per line, or upload a text file.
  2. Choose Compress (RFC 5952) or Expand (full form) under Output.
  3. Copy or download the Result. Lines that are not valid addresses are marked and explained above it.

How it works

Every address is first read into its 128 bits, so any valid spelling gives the same result. Compression then follows RFC 5952:

  • Hex digits are lowercase, and leading zeros in each group are dropped (0db8 → db8).
  • The longest run of two or more all-zero groups becomes ::. When two runs are equally long, the first one is shortened.
  • A single zero group stays as 0; it is never replaced by ::.

Expansion writes all 8 groups with 4 digits each, the form some firewalls and reverse DNS zones need.

Examples

  • 2001:0db8:0000:0000:0000:ff00:0042:8329 → 2001:db8::ff00:42:8329.
  • 2001:db8:0:0:1:0:0:1 → 2001:db8::1:0:0:1 (two equal zero runs, the first is shortened).
  • 2001:db8:0:1:1:1:1:1 stays 2001:db8:0:1:1:1:1:1 (a single zero group is not shortened).
  • ::1 expands to 0000:0000:0000:0000:0000:0000:0000:0001.

Limitations

  • A prefix such as /64 or a zone index such as %eth0 on a line makes that line invalid. Remove it first, or use the IPv6 CIDR Calculator for prefixes.
  • Addresses with a dotted IPv4 tail are accepted, but the output is written fully in hex.
  • Live results run for inputs up to 200 KB. Larger files convert when you press Convert.

Frequently asked questions

What is the shortest way to write an IPv6 address?

The RFC 5952 form: lowercase, no leading zeros in a group, and the longest run of zero groups written as ::. It is also the form you should use in documentation and logs.

Can :: appear twice in one address?

No. If it did, nobody could tell how many zero groups each :: stands for, so an address with two is invalid.

Are uppercase and lowercase IPv6 addresses the same?

Yes, the hex digits mean the same thing in either case. RFC 5952 recommends lowercase so addresses compare cleanly as text.

Often used together with the IPv6 Compress / Expand.