IPv6 Address Formats, Shortening and Prefixes
An IPv6 address is 32 hex digits in eight quartets. Two rules shorten it: drop the leading 0s in each quartet, then replace one run of two or more all-0 quartets with a double colon, ::. Devices usually show the shortest form. To expand, add the leading 0s back and fill the :: with enough 0000 quartets to make eight.
By Arif, founder of Daveth · Updated
The full 12 min walkthrough is in Daveth Pro (Network). See what the plan opens
What this page answers
How do you shorten an IPv6 address?
Rule 1: in each quartet, drop the leading 0s. Rule 2: replace one string of two or more all-0 quartets with ::. 2001:0DB8:0A50:0000:0000:0000:0000:0000 becomes 2001:DB8:A50::. Read it in “Rule 2: one double colon”
How do you expand a shortened IPv6 address?
Add leading 0s until each quartet has four hex digits, then count the quartets you can see and replace :: with enough 0000 quartets to make eight in total. Read it in “Back to 32 digits”
Eight quartets
Tuesday, month five, week one. The ISP's follow-up email arrives with the company's prefix written out in full, and the address of a test server the ISP runs for its customers:
2001:0DB8:0A50:0000:0000:0000:0000:0000 /48
2001:0DB8:00F0:0000:0000:0000:0000:0053 /64
Ravi checks the ISP's customer website, which shows the prefix as 2001:DB8:A50::/48, and shares both on a call with Maya. Maya asks which one is right. Both are: they're the same prefix, written two ways. By the end of this page, you'll be able to prove it.
The ISP typed 32 digits so the website could show 10. Somebody's keyboard had a long morning.
Working with IPv6 addresses takes the same skills as IPv4 addresses, with bigger numbers:
- reading and writing a full, unabbreviated address
- abbreviating an address, and expanding an abbreviated one
- reading the prefix length, the IPv6 version of a prefix-style mask
- finding the prefix (the IPv6 subnet ID) from an address and its prefix length
A full IPv6 address is eight sets of four hex digits, separated by colons, like the email's. This course calls one set of four hex digits a quartet, so every address has eight quartets. The IPv6 RFCs don't use that word (some people say "hextet" instead), but it names the thing you're counting.
Most of the time, the hex is all you need. When you do need the bits, the conversion is easy: each hex digit is exactly 4 bits, so a quartet is 16 bits and eight of them make 128.
| Hex | Binary | Hex | Binary |
|---|---|---|---|
| 0 | 0000 | 8 | 1000 |
| 1 | 0001 | 9 | 1001 |
| 2 | 0010 | A | 1010 |
| 3 | 0011 | B | 1011 |
| 4 | 0100 | C | 1100 |
| 5 | 0101 | D | 1101 |
| 6 | 0110 | E | 1110 |
| 7 | 0111 | F | 1111 |
Rule 1: drop the leading 0s
32 hex digits beat 128 bits, but they're still a lot to remember, spot in command output and type. So IPv6 defines ways to abbreviate an address. And you can't avoid the short forms even if you like the long ones: computers and routers typically show the shortest abbreviation, even when you typed all 32 digits. That's why the website shows ten.
Two rules shorten an address. The first works inside each quartet on its own:
Rule 1. In each quartet, remove the leading 0s, the 0s on the left, in the three left-hand positions. A quartet of 0000 keeps a single 0.
Apply it to the email's prefix: 0DB8 becomes DB8, 0A50 becomes A50, and each 0000 becomes 0:
2001:DB8:A50:0:0:0:0:0
Look at A50 in the prefix. The 0 on its right stays: it's a trailing 0, and removing it would change the value.
Rule 2: one double colon
Rule 2. Find a string of two or more quartets in a row that are all 0s, and replace the whole string with a double colon, ::. The :: means "two or more quartets of all 0s". The prefix's five 0 quartets collapse into one ::, and that's the website's version:
2001:DB8:A50::
Rule 2 is optional in the sense that rule 1 alone already gives a valid abbreviation, just not the shortest. Some addresses have more than one string of 0 quartets, though.
You can use :: only once in an address. With two of them, nobody can tell how many quartets of 0s each one stands for, so the exact address is no longer clear.
You can think of the :: as the "..." in a list that always has exactly eight entries: "1, 2, ..., 7, 8" tells you precisely what's missing, because the count never changes. (Where it stops: with counting numbers, "1, ..., 4, ..., 8" can still be filled in from the numbers themselves; quartets aren't in counting order, so two :: give no way to tell how many 0 quartets go in each gap.)
When there's a choice, pick the longest string of 0 quartets for the ::. In 3A00:0000:0000:0010:0000:0000:0000:0B00, the string of three near the end wins over the pair near the front:
3A00:0:0:10::B00
If two strings tie for longest, either one can take the ::; both results are valid and equally short.
That example also shows the two most common mistakes, both of which it avoids:
- Removing trailing 0s. 3A00 can't be shortened at all, because both its 0s trail. Writing 3A would mean 003A.
- Using :: twice. 3A00::10::B00 is wrong, because nobody could tell how many 0 quartets belong in each gap.
Only the zeros at the front of a quartet get to leave early. The ones at the back are holding the value up.
It accepts any written form, full or short, and it refuses anything the two rules can't produce, saying why.

Back to 32 digits
Expanding reverses the two rules.
- In each quartet, add leading 0s until it has four hex digits.
- If there's a ::, count the quartets you can see; there will be fewer than eight. Replace the :: with enough quartets of 0000 to make eight in total.
The test server, which the website lists as 2001:DB8:F0::53, shows four quartets, so the :: stands for four:
2001:0DB8:00F0:0000:0000:0000:0000:0053
Now Maya's question has a proof: expand 2001:DB8:A50:: and you get the email's 32 digits exactly.
Continue the lesson
The whole lesson, with its drawings and its questions. 3 more sections after the ones above.


