IPv6 Compressor |
IPv6 Compressor — Shorten Any IPv6 Address to RFC 5952 Canonical Form
IPv6 address compression converts a full 128-bit hexadecimal address — written as eight groups of four digits separated by colons — to the shortest valid notation defined by RFC 5952 (August 2010). Two rules apply: (1) leading zeros within each 16-bit hextet are stripped, and (2) the longest consecutive sequence of all-zero hextets is replaced by a double colon (::), which may appear only once. Compressed and expanded forms represent the same address — the underlying value is unchanged.
| Property | Detail |
|---|---|
| Input format | Full 128-bit IPv6 address — 8 hextets of up to 4 hex digits each |
| Rule 1 (§4.1) | Strip leading zeros in every hextet — 0db8 → db8 |
| Rule 2 (§4.2) | Replace longest consecutive all-zero run with :: — once per address only |
| Tiebreak (§4.2.3) | When two runs share equal length, the leftmost is compressed |
:: minimum (§4.2.2) |
:: applies only to runs of 2 or more consecutive zero hextets |
| Output case (§4.3) | Lowercase hexadecimal — 2001:DB8::1 is non-canonical |
How to Use the IPv6 Compressor
Enter any full or partially compressed IPv6 address and get the canonical short form in seconds — single address or bulk list.
Click Compress IPv6
Read the Compressed Result
Copy and Use the Result
How IPv6 Compression Works — RFC 5952 Rules
RFC 5952 (August 2010) standardizes the canonical text representation of IPv6 addresses to eliminate format inconsistencies that caused failures in log auditing, string comparison, and certificate validation. Four requirements are relevant to this tool:
-
§4.1 — Suppress leading zeros. Every leading zero within a 16-bit hextet
must be removed.
0042becomes42;0000becomes0. Trailing zeros within a hextet are never removed. -
§4.2.2 — Single zero group stays explicit.
::must not shorten a single isolated zero hextet.2001:db8:0:1:2:3:4:5compresses to2001:db8:0:1:2:3:4:5— the0remains; no::is applied. -
§4.2.3 — Leftmost wins on equal-length ties. When two consecutive zero
runs share the same length, the leftmost is compressed.
2001:0:0:1:0:0:3:4→2001::1:0:0:3:4, not2001:0:0:1::3:4. -
§4.3 — Lowercase only. All hexadecimal digits must be lowercase.
2001:DB8::1is non-canonical;2001:db8::1is correct.
The canonical form matters beyond readability. DNS AAAA records (RFC 3596) and BGP routing
tables store addresses in canonical form. Application code comparing IPv6 strings without
normalization produces false negatives — 2001:db8::1 and
2001:0db8:0:0:0:0:0:1 are the same address but fail a naive string equality check.
Command line
How to Compress an IPv6 Address Without an Online Tool
Mac / Linux Python 3
python3 -c "import ipaddress; print(str(ipaddress.ip_address('2001:0db8:0000:0000:0000:ff00:0042:8329')))"
Output: 2001:db8::ff00:42:8329. Python's ipaddress module follows RFC 5952.
Windows PowerShell
[System.Net.IPAddress]::Parse('2001:0db8:0000:0000:0000:ff00:0042:8329').IPAddressToString
Output: 2001:db8::ff00:42:8329. The .NET IPAddress class normalizes to canonical form.
The bulk list mode in this tool is faster when compressing many addresses at once without writing a script, or when working on a machine without Python installed.
Common Uses for IPv6 Address Compression
Firewall and ACL configuration. A network engineer is adding IPv6-based access control rules to a Cisco IOS router. The router CLI rejects non-canonical notation with a "% Ambiguous command" error. Compressing addresses before entry eliminates the error and ensures rules match what the routing table stores.
DNS AAAA record provisioning. A DevOps engineer is setting a DNS AAAA record
for a dual-stack web server. The output of ip addr show on Linux returns the
expanded form. Compressing it to canonical notation before pasting into the DNS registrar's
portal ensures the record is accepted and consistent with PTR record lookups.
Application-level address normalization. A Python developer is storing IPv6
client addresses in a database and comparing them against block lists. Inconsistent notation
— 2001:db8::1 from one source and 2001:0db8:0:0:0:0:0:1 from
another — causes false negatives in equality checks. Normalizing all addresses to RFC 5952
canonical form at ingestion eliminates the mismatch.
Frequently Asked Questions
What is the double colon (::) in an IPv6 address?
Why does my result not show :: even though the address contains zeros?
Does compressing an IPv6 address change its value or routing behavior?
What is the difference between a compressed and an expanded IPv6 address?
How do I compress an IPv6 address from the command line?
python3 -c "import ipaddress; print(str(ipaddress.ip_address('2001:0db8:0000:0000:0000:ff00:0042:8329')))". On Windows PowerShell: [System.Net.IPAddress]::Parse('2001:0db8:0000:0000:0000:ff00:0042:8329').IPAddressToString. Both output the canonical compressed form. The bulk list mode in this tool is faster when processing many addresses without writing a script.