How to Expand an IPv6 Address

Write an IPv6 address out in full: restore the zero groups that :: stands for and pad every group to four hex digits. With a step-by-step worked example.

Updated 5 min read By CodingEagles
Free tool IPv6 Expand Expand a shortened IPv6 address to all eight full groups. Open tool

A short IPv6 address like 2001:db8::ff00:42:8329 hides two things: a run of zero groups behind the ::, and the leading zeros dropped from each group. Expanding it means putting both back, so you end up with the full eight groups of four hex digits. The IPv6 expand tool does this instantly, and the method is two steps.

Step one: undo the ::

The :: stands for a run of all-zero groups, however many are needed to make eight groups in total. To work out how many, count the groups actually written and subtract from eight.

Take 2001:db8::ff00:42:8329. The written groups are 2001, db8, ff00, 42, 8329, which is five. So the :: must stand for 8 − 5 = 3 zero groups. Drop them in where the :: was:

2001:db8:0:0:0:ff00:42:8329

Now there are eight groups. The :: can appear at most once in an address, which is what makes this count unambiguous.

Step two: pad each group to four digits

Every group in the full form is four hex digits, so add leading zeros to any group that is shorter:

2001  →  2001
db8   →  0db8
0     →  0000
ff00  →  ff00
42    →  0042
8329  →  8329

Putting it together gives the fully expanded address:

2001:0db8:0000:0000:0000:ff00:0042:8329

That is the same value as the short form, just written without any abbreviation.

A note on the ends

When :: sits at the very start or end of an address, the same counting still works. ::1 has one written group, so :: covers seven zero groups, expanding to 0000:0000:0000:0000:0000:0000:0000:0001. The all-zeros address :: has no written groups, so it expands to eight zero groups.

Embedded IPv4 addresses

Some IPv6 addresses end in a dotted-quad, such as ::ffff:192.0.2.5. To expand these, convert the IPv4 tail into two hex groups first: 192.0.2.5 becomes c000:0205. Then expand as usual, giving 0000:0000:0000:0000:0000:ffff:c000:0205. How those mapped and 6to4 forms are built is covered in how to convert IPv4 to IPv6.

When you need the full form

Most systems accept the short form happily, so why expand at all? A few reasons come up. Some older software and a few command-line tools only take the full eight-group spelling. Exact text matching, such as grepping logs or comparing two addresses character by character, is easier when both are written out fully and there is only one possible spelling. And when you are learning the layout, seeing all eight 16-bit groups makes the structure of an address clear in a way the compressed form hides.

Expanding and compressing are exact inverses. If you expand an address and then compress it again, you get back the canonical short form; the rules for that direction are in how to compress an IPv6 address. Neither operation ever changes the address.

Do it in one step

Counting zero groups by hand is easy to get wrong, especially with :: at one end. Paste the short address into the IPv6 expand tool and it writes out all eight groups for you, with the compressed form shown alongside so you can check the two match.

Frequently asked questions

How do I expand a shortened IPv6 address?
Two steps. First replace :: with enough all-zero groups to bring the total to eight. Then pad each group to four hex digits with leading zeros. So 2001:db8::ff00:42:8329 expands to 2001:0db8:0000:0000:0000:ff00:0042:8329.
How many zero groups does :: stand for?
As many as are needed to reach eight groups total. Count the groups written on each side of the ::, add them, and subtract from eight. In 2001:db8::ff00:42:8329 there are five written groups, so :: stands for three zero groups.
Does expanding change the address?
No. Expanding only restores zeros that the short form left out, so the 128-bit value is identical. The full and compressed forms are interchangeable everywhere an IPv6 address is accepted.

Ready to try it?

Expand a shortened IPv6 address to all eight full groups. Free, in-browser, and 100% private — your data never leaves your device.

Open the IPv6 Expand