How is an IPv6 address written, and what does zero compression (::) do?
An IPv6 address is eight groups of four hex digits separated by colons. Two separate shortening rules apply: leading zeros inside a group are dropped (0000 → 0), and a single run of all-zero groups can be collapsed to ::.
Notation:
- 128 bits split into 8 groups of 16 bits, each written as 4 hexadecimal digits, separated by colons
- Example:
69DC:8864:FFFF:FFFF:0:1280:8C0A:FFFF
Two distinct compression rules — don't confuse them:
1. Leading-zero suppression (within a single group). Inside each 16-bit group you may drop leading zeros, so 0000 shrinks to 0, 00A3 to A3, 0DB8 to DB8. This is why you see a lone :0: rather than :0000: — the group still exists, it's just written with its leading zeros stripped down to a single 0:
2001:0DB8:0000:1428:0000:0000:0000:57AB
→ 2001:DB8:0:1428:0:0:0:57AB (leading zeros dropped)
2. Run compression with :: (across whole zero groups). One — and only one — consecutive run of all-zero groups may be replaced entirely by :::
FF0C:0:0:0:0:0:0:B1 → FF0C::B1
The reader can reconstruct the missing groups because the total must be 8 groups — so :: expands to "however many all-zero groups are needed to reach 8."
Applying both to the example above: 2001:DB8:0:1428::57AB (leading zeros stripped, then the three-group zero run compressed to ::).
Tip: :0: = one group whose leading zeros were dropped; :: = a whole run of zero groups removed. You can use :: only once per address — otherwise it would be ambiguous how many zero groups go on each side.
Go deeper:
IPv6 address — Address representation (Wikipedia) — worked examples of grouping, leading-zero suppression, and the
::rule.