InfyCalculator
💻

IPv6 Expand & Compress Calculator

Expand a shortened IPv6 address to its full eight-group form, or compress a full address to the canonical RFC 5952 short form.

IPv6 address
Convert to
Loading calculator…

How it works

expand: pad each of 8 groups to 4 lowercase hex digits · compress (RFC 5952): drop leading zeros per group, then replace the single longest run (≥2) of all-zero groups with "::" (leftmost run on a tie)

An IPv6 address is 128 bits written as eight 16-bit groups of hexadecimal. Two shorthands make it readable: leading zeros inside a group may be dropped (0db8 → db8), and one run of consecutive all-zero groups may be replaced by "::". Because "::" is only allowed once, the canonical RFC 5952 form uses it on the longest zero run — and the leftmost one when two runs tie — with everything in lowercase. Expanding reverses both shorthands so you can compare or sort addresses byte-for-byte.

Worked example

The address 2001:db8::1 expands to 2001:0db8:0000:0000:0000:0000:0000:0001 — the "::" stands in for five zero groups, and each group is padded to four digits. Compressing that full form runs the rules the other way and returns 2001:db8::1.

Sources: RFC 5952 — IPv6 text representation · RFC 4291 — IPv6 addressing

Frequently asked questions

Why can "::" appear only once in an address?

Because it means "as many zero groups as needed to reach eight". Two of them would be ambiguous — there would be no way to know how many zero groups belong to each. The parser here rejects any address with more than one "::".

What does RFC 5952 add on top of the older shorthand rules?

It makes the short form canonical: lowercase only, no leading zeros, "::" applied to the longest zero run (the first one if two are equal length), and never used to shorten just a single zero group. That gives every address exactly one correct textual form, which matters for logs, allowlists and string comparisons.

Is an expanded address different from the compressed one?

No — they are the same 128-bit value written two ways. Expansion is purely cosmetic, useful when you need every address to line up at the same width or want to compare two addresses that were written with different shorthand.

Related calculators

This calculator is for educational purposes. Double-check important results before acting on them.