Compress IPv6 Address

Paste any IPv6 address to get its shortest correct compressed form, its fully expanded form, and a group-by-group breakdown. Done to the RFC 5952 rules, in your browser.

Other Tools

Why IPv6 addresses need compressing

A full IPv6 address is eight groups of four hexadecimal digits: 2001:0db8:85a3:0000:0000:8a2e:0370:7334 — 39 characters before you have typed anything else. Fortunately the notation has two legal shortcuts, and applying them properly is exactly what this tool does:

  1. Drop leading zeros in each group — 0db8 becomes db8, 0370 becomes 370, 0000 becomes 0.
  2. Replace one run of zero groups with :: — the longest run of consecutive all-zero groups collapses into a double colon.

Applied together, the example becomes 2001:db8:85a3::8a2e:370:7334 — the same address, 15 characters shorter.

The rules that trip people up

  • :: may appear only once. Two :: in one address would be ambiguous — you could not tell how many zero groups each one replaces. If two runs tie for longest, RFC 5952 says compress the first.
  • A single zero group should not be compressed. Replacing one 0 group with :: saves nothing and the standard recommends against it; the group is written as 0 instead. (This tool follows the standard; some systems differ.)
  • Hex is case-insensitive, but lowercase is the recommended canonical form.
  • The last 32 bits may be written as IPv4 — ::ffff:192.168.1.1 is legal mixed notation, common for mapped addresses.

Diagram of the eight 16-bit groups of an IPv6 address and how zero runs compress to a double colon

Expand mode: the reverse direction

Sometimes you need the opposite: the full, unambiguous form for matching patterns in logs, writing firewall rules, or comparing two addresses that look different. The tool's expanded view restores every group to four digits with all zeros written out — the form in which two spellings of the same address become visibly identical. A surprising number of "different" addresses in mixed logs turn out to be the same host wearing compressed and expanded spellings.

Validation built in

The tool parses the address strictly before compressing: wrong group counts, non-hex characters, double :: and misplaced colons are rejected with a plain-English error. That makes it a handy checker when a config file, DNS record or access-control list rejects an address and you need to know whether the address or the system is at fault.

Where compressed form matters

  • DNS records — AAAA records are usually published compressed; consistency avoids confusion.
  • Documentation and tickets — shorter addresses get copied correctly more often.
  • Log analysis — normalise everything to one spelling (compressed or expanded) before searching, or the same host hides under several strings.
  • Interviews and exams — the :: rules are a favourite question; the group-by-group breakdown here shows the working, not just the answer.

Related converters

Working with a mapped address? The IPv6 to IPv4 Converter pulls the IPv4 out of ::ffff: forms, and the IPv4 to IPv6 Converter builds them. Once an address is in the form you need, the IP Lookup shows who and where it is.

Hand-checking a compression, worked end to end

Take fe80:0000:0000:0000:0202:b3ff:fe1e:8329 (a typical link-local address from a router label). Step one, strip leading zeros group by group: fe80, 0, 0, 0, 202, b3ff, fe1e, 8329. Step two, find the longest zero run: groups two to four — three zeros in a row, the only run, so it earns the ::. Result: fe80::202:b3ff:fe1e:8329. Count the visible groups to verify: fe80 (1) + :: + four groups = the :: is hiding exactly three groups, 1+3+4 = 8. ✓

Now the trap case: 2001:0db8:0000:0001:0000:0001:0000:0001 has three separate single zero groups and no runs at all. Nothing compresses except leading zeros: 2001:db8:0:1:0:1:0:1. Beginners often write 2001:db8::1:0:1:0:1 — wrong, because that :: would claim a run that does not exist and produce a different address. When in doubt, paste it above: the tool applies the run rules exactly and validates the result.

Frequently asked questions

How do I compress an IPv6 address manually?

Two steps: remove leading zeros in every group (0db8 → db8), then replace the longest single run of zero groups with ::. The :: may be used only once, and a lone zero group is written as 0 rather than compressed.

Why can't an address contain two :: ?

Each :: stands for "enough zero groups to complete the address". With two of them, the split between the two runs would be unknowable, so the notation forbids it.

Does compressing change the address?

No. Compressed and expanded forms are spellings of the identical 128-bit address. Every device treats 2001:db8::1 and 2001:0db8:0000:0000:0000:0000:0000:0001 as the same destination.

What is the shortest possible IPv6 address?

::1 (loopback) and :: (unspecified) — three and two characters. A typical global address compresses to around 20–30 characters depending on how many zero groups it contains.

Which run of zeros gets the :: if two runs are equal?

The first one, per RFC 5952. The tool follows that rule so its output matches the canonical form other standards-compliant systems produce.

Looking for something else? Browse all 15 free IP tools or read the router guides on the blog.