Utilities

IPv6 Compressor

Shorten an IPv6 address using standard zero compression.

Processed in your browser

An IPv6 address written in full has eight groups of four hexadecimal digits, 39 characters in all, and many of those characters are usually zeros. The IPv6 Compressor rewrites an address in its shortest standard form: 2001:0db8:0000:0000:0000:0000:0000:0001 becomes 2001:db8::1.

Both forms are the same address. Only the spelling changes. Your browser does the rewriting: the page is marked "Processed in your browser", and the IP Tracker server does not receive the address.

How to compress an address

  1. Paste or type an IPv6 address into the field. It can be the full form or a partly shortened one.
  2. Click Calculate.
  3. Copy the short form from the Result row.

Enter the address on its own, without a prefix length such as /64 and without square brackets. Anything that is not a valid IPv6 address, an IPv4 address included, gets the message "Enter a valid IPv6 address."

Under the rows, "View as JSON", Copy JSON and Download JSON give the same two values as JSON.

How to read the result

The result has two rows. Input repeats what you entered, so you can check that nothing was lost when you pasted. Result is the compressed address.

If the two rows are identical, the address was already in its shortest form. If you get the error message instead of a result, the input is not a valid address. Frequent causes are a hand-shortened address with a double colon in two places, and an address with fewer than eight groups and no double colon at all.

How an IPv6 address is written

An IPv6 address is 128 bits long. Written out, the bits are split into eight groups of 16 bits, and each group is shown as four hexadecimal digits with colons between the groups. Hexadecimal is a base-16 counting system that uses the digits 0 to 9 and the letters a to f, so one digit stands for 4 bits.

Real addresses contain many zeros. Large parts of an assigned block often go unused, and servers are commonly given low numbers such as 1 or 2 inside their network. The notation has two rules for leaving those zeros out.

The two shortening rules

The first rule removes leading zeros inside each group. 0db8 becomes db8, 0001 becomes 1, and a group of four zeros becomes a single 0. Only zeros at the front of a group go. db80 keeps its last zero, because removing it would change the value.

The second rule replaces a run of groups that are all zero with a double colon, ::. The double colon means "as many zero groups as it takes to make eight". In 2001:db8:0:0:0:0:0:1, five zero groups in a row collapse and leave 2001:db8::1.

The double colon can appear only once in an address. With two of them, a reader could not tell how many zero groups each one stands for. 2001:db8::1::2 could mean several different addresses, so it is not valid.

These two rules alone would still allow several short spellings of one address. The standard form, described in RFC 5952, adds tie-breakers so that every address has exactly one.

  • When an address has more than one run of zero groups, the longest run is replaced.
  • When two runs are equally long, the first one is replaced.
  • A single zero group on its own is written as 0, not as a double colon.
  • The letters a to f are written in lowercase.

How to compress an address by hand

  1. Write the address with all eight groups, if it is not already in that form.
  2. Remove the leading zeros of every group. A group of four zeros becomes 0.
  3. Mark every run of two or more 0 groups that stand next to each other.
  4. Replace the longest run with a double colon. If two runs tie, take the one on the left.
  5. Change any capital letters to lowercase.

For 2001:0DB8:0000:0000:0012:0000:0000:0034, the second step gives 2001:DB8:0:0:12:0:0:34. There are two runs of two zero groups, so the left one is replaced: 2001:DB8::12:0:0:34. Lowercase letters finish it: 2001:db8::12:0:0:34.

Worked examples

Full formCompressedWhat happened
2001:0db8:0000:0000:0000:0000:0000:00012001:db8::1Leading zeros removed and five zero groups replaced
2001:0db8:85a3:0000:0000:8a2e:0370:73342001:db8:85a3::8a2e:370:7334Two zero groups replaced, and 0370 shortened to 370
2001:0db8:0000:0001:0000:0000:0000:00012001:db8:0:1::1Two runs of zeros. The longer one is replaced and the single zero group stays as 0
2001:0db8:0000:0000:0001:0000:0000:00012001:db8::1:0:0:1Two runs of equal length. The first one is replaced
2001:0DB8:00A0:0000:0001:0002:0003:00042001:db8:a0:0:1:2:3:4Only one zero group, so no double colon. Letters changed to lowercase
fe80:0000:0000:0000:0202:b3ff:fe1e:8329fe80::202:b3ff:fe1e:8329Three zero groups replaced
2001:0db8:0000:0000:0000:0000:0000:00002001:db8::The run of zeros reaches the end, so the address ends in a double colon

Take the third row step by step. Removing leading zeros gives 2001:db8:0:1:0:0:0:1. There are two runs of zero groups: one group in third position, and three groups in positions five to seven. The longer run becomes the double colon, which leaves 2001:db8:0:1::1.

Common mistakes when shortening by hand

  • Dropping zeros from the end of a group. 2001:db80::1 and 2001:db8::1 are different addresses.
  • Using the double colon twice, once for each run of zeros. The result is not a valid address, and the tool answers with the error message.
  • Replacing the shorter run. 2001:db8::1:0:0:0:1 is a valid address, but its standard spelling is 2001:db8:0:1::1. The tool accepts the first and returns the second.
  • Losing or gaining a group while counting. An address with nine groups, or with seven groups and no double colon, is rejected.

Why one standard short form matters

The notation allows many spellings of one address. 2001:db8::1, 2001:DB8:0:0:0:0:0:1 and 2001:0db8::0001 are all valid and all mean the same thing. A person can see that they match. A text search treats them as three different strings.

That causes confusion in daily work. A search of a log file for an address finds nothing because the log wrote it in another spelling. A list of allowed addresses contains the same host twice and nobody notices. When every address is written in the one standard form, two addresses are equal exactly when their text is equal.

Many current operating systems and network tools print addresses in this form, so an address compressed here should match what you see in command output and logs.

Special addresses that are mostly zeros

CompressedFull formMeaning
::10000:0000:0000:0000:0000:0000:0000:0001The loopback address, the IPv6 counterpart of 127.0.0.1
::0000:0000:0000:0000:0000:0000:0000:0000The unspecified address, used to mean "no address" or "any address"
fe80::1fe80:0000:0000:0000:0000:0000:0000:0001A link-local address, valid only on the local network segment
ff02::1ff02:0000:0000:0000:0000:0000:0000:0001The multicast address for all devices on the local link
2001:db8::2001:0db8:0000:0000:0000:0000:0000:0000The start of the range reserved for examples in documentation

In :: the double colon stands for all eight groups, and in ::1 for the first seven. An address cannot get much shorter than that, and both are valid input here.

Where a compressed address helps

  • Comparing the AAAA record that DNS Lookup returns for a domain with the address configured on the server, when the two were written by different people or programs.
  • Cleaning a list of addresses before removing duplicates.
  • Checking an address you shortened by hand. If your version and the Result row differ, the Result row has the standard spelling. If the tool reports an error, the hand-written version was not valid.
  • Preparing an address for documentation, a ticket or a configuration file, where the short form is easier to read and less likely to be mistyped.

What the compressor does not do

The tool rewrites text. It does not check whether the address exists, responds or is assigned to anyone. To see network and location data for a public address, use IP Lookup.

It handles one address at a time and takes no prefix length. A block such as 2001:db8::/32 has to be entered without the /32. IPv4 addresses are not accepted.

For the opposite direction, IPv6 Expander writes an address out as eight full groups. That is the form to use for sorting and for building reverse DNS names.

Frequently asked questions

Why can the double colon be used only once?

Because the double colon has no fixed length. It stands for however many zero groups are missing. With one double colon the count is clear: eight minus the groups that are written. With two, the missing groups could be divided between them in more than one way, and the address would be ambiguous.

Is 2001:db8::1 the same address as 2001:0db8:0000:0000:0000:0000:0000:0001?

Yes. They are two ways of writing the same 128 bits. A device configured with one answers to the other, and a rule written with one matches the other.

Should the letters in an IPv6 address be uppercase or lowercase?

Both are valid, and software reads them the same way. The recommended form is lowercase, and that is what the Result row uses. Sticking to lowercase avoids mismatches in tools that compare addresses as text.

Why did a single group of zeros stay as 0?

The standard form uses the double colon only for two or more zero groups in a row. One zero group on its own is written as 0. Replacing it would save a single character.

So 2001:db8:a0:0:1:2:3:4 is already as short as the standard form gets.

Can I remove zeros at the end of a group?

No. Only leading zeros can go. A group is a number, and trailing zeros are part of its value, just as 10 and 1 are different numbers. The group a000 cannot be written as a, while 000a can.

How do I use an IPv6 address in a web address or with a port?

Put square brackets around it, as in http://[2001:db8::1]/ or [2001:db8::1]:8080. The brackets keep the colons of the address apart from the colon that introduces the port number.

Add the brackets yourself after compressing. They are not part of the address, and the tool does not accept them as input.

What if my address has a prefix such as /64?

Remove the prefix, compress the address, and put the prefix back. The prefix length is not part of the address. 2001:0db8:0000:0001:0000:0000:0000:0000/64 becomes 2001:db8:0:1::/64.

Is the address I enter sent to a server?

No. The compression is done in your browser and the address is not sent to the IP Tracker server. IP Tracker does not keep a history of what visitors look up.