Guide
Writing IPv6 addresses in the canonical short form of RFC 5952
IPv6 allows many correct spellings of one address, which is fine for a router and a nuisance for humans and scripts. Searching a log, comparing two configuration files, or de-duplicating a list only works if everybody writes an address the same way. RFC 5952 defines that single recommended text form, and this page converts a list of addresses into it.
The rules
The canonical form follows five rules. Leading zeros in each group are removed (0db8 becomes db8). Hexadecimal letters are lower case. The longest run of two or more consecutive all-zero groups is replaced with ::. If two runs have the same length, the first one is replaced. And :: must never stand for just one group: a lone zero group is written as 0. The page applies these to every line. If the line carries a prefix length, such as /64, the prefix is left as typed.
The cases that are easy to get wrong
Choosing the longest run, not the first: in 2001:0:0:1:0:0:0:1 the second run has three zero groups and the first has two, so the result is 2001:0:0:1::1. Ties: in 2001:db8:0:0:1:0:0:1 both runs have two groups, so the first is shortened to give 2001:db8::1:0:0:1. Single zeros: 2001:db8:0:1:1:1:1:1 has one zero group, so it stays as written. Whole-address zero is ::, and the loopback address is ::1. These are exactly the places where hand-written addresses disagree with what operating systems print.
IPv4-mapped addresses
An address that embeds an IPv4 address in its last 32 bits is normally printed in hexadecimal, ::ffff:c000:201. Many tools print it with a dotted ending instead, ::ffff:192.0.2.1. RFC 5952 permits the dotted ending for addresses that embed an IPv4 address. A switch on the page chooses which style you receive.
A worked example
The sample list produces five lines. 2001:0db8:0000:0000:0000:ff00:0042:8329 becomes 2001:db8::ff00:42:8329 (the three middle zero groups collapse). The tie case becomes 2001:db8::1:0:0:1. The loopback address comes back as ::1. An EUI-64 style link-local address is reduced to fe80::202:b3ff:fe1e:8329, and the mapped address ::ffff:c000:201 stays in hexadecimal until you switch on the dotted option, when it reads ::ffff:192.0.2.1.
Limits
The page changes spelling only. It does not decide whether an address is valid for your network, and it does not touch a prefix. Text that is not an IPv6 address gets an error message on its line. To go the other way and see all 32 digits, use the IPv6 Expander.
Why one spelling matters
Tools disagree about how to print an address: a router may show 2001:db8:0:0:1:0:0:1, a Linux host 2001:db8::1:0:0:1 and an old script the fully padded form. Compare logs, access lists or inventories by text and the same address appears to be three different ones. Run the whole list through the compressor first, then sort and remove duplicates, and the comparison becomes reliable. The same applies to addresses embedded in URLs and configuration files, where square brackets surround the address and a zone identifier such as %eth0 can follow it.
Checking a result by hand
To verify a result, expand it again. Count the groups that are present, subtract from eight and you know how many zero groups the :: hides: 2001:db8::1:0:0:1 shows six groups, so the double colon stands for two zero groups. If expanding the compressed text gives back the original address, nothing was lost.
Related tools
- IPv6 Expander restores the full 39-character form.
- IPv6 Subnet Calculator describes the range covered by a prefix.
- IPv4 to IPv6 Converter builds the mapped and NAT64 forms.
- Diff Checker compares two compressed address lists line by line.
Checked against the current version of the IPv6 Compressor on .

