Using the converter
Paste one address per line, in any form. Each comes out in its compressed form, and a prefix such as /64 on the end is kept. Swap the direction to expand addresses instead, with every group written as four hex digits.
The steps show the rules applied to the first address. A line that isn't an address stops the conversion with a message saying why.
The rules for compressing
RFC 4291 allows many ways to write one address. RFC 5952 picks one of them, so that the same address always looks the same in logs and configs. There are only a few rules.
Leading zeros in each group are dropped, so 0db8 becomes db8 and 0000 becomes 0. Hex letters are written in lower case.
The longest run of zero groups becomes ::. If two runs tie, the first one is shortened. :: can only appear once, or nobody could tell how many zeros each one stood for. A single zero group is left as 0, since :: would save nothing.
One more case. An IPv4-mapped address, starting ::ffff:, keeps the last 32 bits as an IPv4 address, as in ::ffff:192.0.2.1.
Worked examples
2001:0db8:0000:0000:0001:0000:0000:0001 has two runs of two zero groups. They tie, so the first is shortened, giving 2001:db8::1:0:0:1.
2001:db8:0:1:0:0:0:1 has a single zero group in third place and a run of three later on. The longer run wins, giving 2001:db8:0:1::1.
Going the other way, fe80::1:2 has three groups written, so :: stands in for five. In full it is fe80:0000:0000:0000:0000:0000:0001:0002.
Questions
Is 2001:db8:0:0:1::1 wrong?
It's a legal address, but not the standard form. RFC 5952 says :: must replace the longest run of zeros, so the canonical form is 2001:db8::1:0:0:1.
Why not use :: for a single zero group?
RFC 5952 forbids it. Writing :0: is as short as ::, so nothing is gained.
Does case matter?
Not to computers. 2001:DB8::1 and 2001:db8::1 are the same address. RFC 5952 asks for lower case so text searches find every copy.
What's the unspecified address?
All 128 bits zero, written ::. RFC 4291 says it is never assigned to an interface. The loopback address, ::1, is the same with the last bit set.
Sources
- RFC 4291: IP Version 6 Addressing Architecture
- RFC 5952: A Recommendation for IPv6 Address Text Representation
Added and reviewed . What's new






