Compress an IPv6 address

Canonicalize an IPv6 address by removing redundant zeroes and groups.

freeworks offlinenothing uploaded
ToolIPv6 Compressor
Input
Output

How it works

Eight 16-bit groups are parsed, leading zeroes are removed, and the longest zero run becomes ::; letters are lowercased. Equal-length runs choose the leftmost under RFC 5952.

  • Lowercase and one longest run make text comparable.
  • Canonical output avoids equivalent spellings.

Worked example

Compress full IPv6 to 2001:db8::1
Shorten 2001:0db8:0000:0000:0000:0000:0000:0001 using :: notation
Input
											2001:0db8:0000:0000:0000:0000:0000:0001
										
Output
												Input: 2001:0db8:0000:0000:0000:0000:0000:0001
Compressed: 2001:db8::1
Expanded: 2001:0db8:0000:0000:0000:0000:0000:0001
											

When to use this

Logs, endpoint configs, and firewall allowlists canonicalize IPv6 text.

Edge cases

  • Only one run may become ::.
  • A tie chooses the leftmost run.
  • IPv4-embedded dotted tails may need preservation.

References