IPv6 Shorthand Calculator

Compress or expand an IPv6 address per RFC 5952: drop leading zeros and use a single :: for the longest zero run. Paste any valid form β€” get canonical shorthand and the full expansion.

Input data

Options

Results

Enter data and click Calculate.

What IPv6 shorthand means

An IPv6 address is 128 bits, written as eight hextets (groups of 4 hex digits) separated by colons, e.g. 2001:0db8:0000:0000:0000:ff00:0042:8329. Shorthand (compressed form) is the same value written shorter per RFC 5952: no unnecessary leading zeros, and at most one :: replacing the longest run of zero hextets.

This calculator accepts any valid form (full, partially shortened, mixed case) and returns the canonical compressed form plus the expanded form β€” useful when comparing logs, ACLs, AAAA records, and host configs.

Compression rules (RFC 5952)

  • Leading zeros in hextets β€” drop them: 0db8 β†’ db8, 0042 β†’ 42. A zero hextet is 0, not an empty field.
  • :: only once β€” it replaces the longest run of at least two consecutive zero hextets. A second :: makes the address ambiguous.
  • Length ties β€” if two zero runs are equally long, compress the leftmost one.
  • Lowercase β€” recommended output uses a–f, not A–F.
  • Do not use :: for a single zero β€” a lone 0 hextet stays as 0 (unless it is part of a longer zero run).

Expanded vs compressed

  • Expanded β€” always 8Γ—4 hex digits: easier sorting, diffs, and naive string matches in firewalls.
  • Compressed β€” clearer in DNS AAAA, interface configs, and docs.
  • Partial shorthand β€” e.g. leading zeros removed but no ::; valid but not canonical. The calculator normalizes to RFC 5952.

Same 128 bits: 2001:0db8:0000:0000:0000:ff00:0042:8329 = 2001:db8::ff00:42:8329.

Common mistakes

  • Using :: twice in one address.
  • Leaving leading zeros in β€œcompressed” form (2001:0db8::1 β€” prefer 2001:db8::1).
  • Confusing hextets with bytes β€” IPv6 groups 16-bit chunks, not IPv4-style octets.
  • Pasting dotted IPv4 without mapping (::ffff:192.0.2.1 is the IPv4-mapped form).
  • Assuming β€œmost zeros on the right” always wins β€” ties go to the left.

Worked examples

1) Documentation prefix

Full input: 2001:0db8:0000:0000:0000:ff00:0042:8329

  • Drop leading zeros β†’ 2001:db8:0:0:0:ff00:42:8329
  • Longest zero run: three hextets 0:0:0 β†’ ::
  • Compressed: 2001:db8::ff00:42:8329

2) Leading zeros only (no ::)

2001:0db8:0001:0002:0003:0004:0005:0006 β†’ 2001:db8:1:2:3:4:5:6 (no two consecutive zero hextets, so no ::).

3) :: only once

2001:db8:0:0:1:0:0:1 β€” two runs of two zeros; compress the left: 2001:db8::1:0:0:1 (RFC 5952 leftmost on a tie).

4) Loopback

0000:0000:0000:0000:0000:0000:0000:0001 β†’ ::1.

5) Link-local

fe80:0000:0000:0000:0202:b3ff:fe1e:8329 β†’ fe80::202:b3ff:fe1e:8329. The fe80::/10 prefix stays; compression only collapses the zero run after it.

6) Leading-zero cleanup only

Input 2001:0db8:0:0:0:0:0:1 is already partly shortened. Canonical: 2001:db8::1 β€” the calculator finishes RFC 5952 (lowercase + a single ::).

Quick cheat sheet: input β†’ shorthand (RFC 5952)

A few canonical pairs β€” paste the left column into the calculator to confirm the result.

Input (expanded / partial)Canonical shorthandRule applied
2001:0db8:0000:0000:0000:ff00:0042:83292001:db8::ff00:42:8329leading zeros + one ::
2001:0db8:0001:0002:0003:0004:0005:00062001:db8:1:2:3:4:5:6leading zeros only (no ::)
2001:db8:0:0:1:0:0:12001:db8::1:0:0:1equal-length runs β†’ compress leftmost
0000:0000:0000:0000:0000:0000:0000:0001::1loopback
fe80:0000:0000:0000:0202:b3ff:fe1e:8329fe80::202:b3ff:fe1e:8329link-local + ::

When to use shorthand in practice

  • AAAA records / docs β€” compressed form is easier for humans; tools normalize anyway.
  • ACL / SIEM logs β€” expanded form can make naive text sorts predictable; or normalize before compare.
  • Router configs β€” IOS/FRR/Linux usually accept both; pick one team convention.
  • Debug β€” if a client β€œwon’t connect”, expand in the calculator and compare bit-for-bit with the interface address (ip -6 addr).

Remember: shorthand does not change the address value β€” only the notation. A typo still compresses into a β€œpretty” wrong address β€” always verify against the source (SLAAC, DHCPv6, VLAN docs).

FAQ β€” IPv6 compression and RFC 5952

Common questions about ::, expanded form, and canonical shorthand.

How do I shorten 2001:0db8:0000:0000:0000:ff00:0042:8329?
Canonical result: 2001:db8::ff00:42:8329 β€” leading zeros drop; three middle zeros become one ::.
Can I use :: more than once?
No. At most one ::; otherwise it is ambiguous how many zeros belong in each gap.
Is 2001:0db8::1 OK?
It is understandable, but canonical form is 2001:db8::1 (no leading zeros in hextets).
When should I use the expanded form?
In logs, spreadsheets, text diffs, and tools that expect fixed 8Γ—4 width. Host config usually prefers compressed.
What is IPv4-mapped?
Addresses like ::ffff:x.x.x.x embed IPv4 in IPv6. Enable the calculator option to see the IPv4 part.
Is ::1 localhost?
Yes β€” the IPv6 loopback, equivalent to 127.0.0.1.
Why does my hand-compressed form differ?
RFC 5952 picks the longest zero run; ties go leftmost. The calculator follows those rules and lowercase output.
Must hex letters be lowercase?
Input may be mixed case; recommended (and calculator) output is lowercase.