IPv6 Compression & Expansion
Use this tool to instantly compress or expand any IPv6 address following RFC 5952 rules. Paste a full 32-digit address to get the shortest valid notation, or expand a compressed address back to its full form — essential for CLI configuration, firewall rules, and low-level scripting.
How to Use the IPv6 Compression Tool
The Two RFC 5952 Compression Rules
RFC 5952 defines exactly how an IPv6 address must be shortened. There are two independent rules that are applied together:
Rule 1 — Remove leading zeros from each 16-bit group. 0db8 becomes db8; 0001 becomes 1.
Rule 2 — Replace the longest consecutive run of all-zero groups with ::. If two runs are equal length, the first is replaced. The :: can only appear once.
Step-by-Step Instructions
- 1Paste any IPv6 address: Fully expanded, partially compressed, or already in
::notation — all formats are accepted. - 2Click Format Address: The tool expands the address to its full 8-group form first, then re-applies RFC 5952 compression rules.
- 3Copy the result you need: Use Compressed for CLI commands and documentation; Expanded for older scripts or tools that can't parse
::; Raw Hex for database storage.
Output Format Reference
| Field | Format Rule | Best Used For |
|---|---|---|
| Compressed | Leading zeros removed; longest zero run replaced with :: | Cisco IOS / CLI, documentation, human-readable configs |
| Expanded | All 8 groups restored to exactly 4 hex digits each | Older firewalls, regex matching, legacy scripts |
| Raw Hex | All colons stripped — 32-character hex string | Database storage, low-level code, binary analysis |
Frequently Asked Questions
Can I use the double colon (::) more than once?
No. The :: notation can only appear once in any IPv6 address. Using it twice creates an ambiguous address because it would be impossible to determine how many zero-groups belong in each compressed section. This tool always follows RFC 5952 and places :: at the longest zero run only.
What happens if two zero runs are the same length?
Per RFC 5952, if two consecutive zero runs are equal in length, the first one is compressed with ::. For example, 2001:0:0:1:0:0:0:1 has a two-group run at positions 1–2 and a three-group run at positions 4–6 — the longer one wins: 2001:0:0:1::1.
Why would I need the expanded form?
Some older network equipment, database schemas, and scripts require the full 32-digit form to process correctly — they cannot parse the :: shorthand. The expanded form is also useful for bitwise comparisons and subnet mask operations where every bit position must be explicit.
What is the Raw Hex format used for?
Stripping all colons produces a 32-character hex string (e.g., 20010db8000000000000000000000001). This format is commonly used for database storage (storing IPv6 in a fixed-width column), binary comparisons in programming, and low-level packet analysis tools.
Does this tool support addresses with prefixes like /64?
Currently the tool processes the address portion only — enter the address without the prefix length (e.g., 2001:db8::1 rather than 2001:db8::1/64). The compression and expansion logic applies only to the 128-bit address itself; prefix lengths are a separate routing concept and do not affect the notation rules.