b2KIT

IPv6 Compressor / Expander

Compress IPv6 addresses to short notation and expand abbreviated IPv6 addresses to full 128-bit format.

Tested tool guide Tested browser tools Checked August 16, 2026

What IPv6 Compressor / Expander does, with a checked example

This converter changes the textual spelling of an IPv6 address without changing its 128-bit value. In expanded form, the address has eight four-digit hexadecimal hextets. In compressed form, leading zeroes disappear and one run of zero hextets can become `::`. The detail most often misread is that shorter text is not a smaller address, a subnet, or a range. Compression produces an equivalent notation; expansion reconstructs every omitted zero so the full eight-hextet layout is visible.

Worked example

A concrete input and expected output from the current implementation.

Input

2001:0002:0000:0000:0000:0000:0000:0005

Expected output

2001:2::5

The input has eight hextets. Removing leading zeroes changes `0002` to `2` and `0005` to `5`; the five consecutive `0000` hextets between them are replaced by one `::`, preserving the same 128-bit value.

How the result is produced

1

Expanding omitted hextets

Each colon-delimited hexadecimal hextet represents 16 bits. When `::` appears, expansion inserts enough `0000` hextets at that position to produce eight hextets in total. Every remaining hextet is left-padded to four digits. Without `::`, an address written entirely as hexadecimal hextets must already contain eight groups, although each group may initially contain one to four digits.

2

Choosing the compressed form

Compression removes leading zeroes from each hextet. It may then replace a consecutive run of all-zero hextets with `::`; only one such replacement is possible in an address. RFC 5952 canonical form selects the longest eligible run, selects the first when equal-length runs tie, and does not use `::` for one zero hextet alone.

Good uses

  • Normalize a fully written address from a device configuration before placing it in compact documentation or a command where shorter IPv6 text is easier to inspect.
  • Expand an address from a log entry so every 16-bit hextet is visible while checking a typo, fixed-width field, or manually assigned addressing plan.
  • Determine whether a zero-padded string and a version containing `::` are merely different textual representations of the same IPv6 address.

Limits and checks

  • This is notation conversion, not subnet analysis. A suffix such as `/64` describes a prefix boundary; converting the address portion does not calculate the subnet, host range, or membership.
  • `::` can occur only once in a valid address and must represent at least one omitted zero hextet. A hexadecimal address that expands to fewer or more than eight hextets is invalid, not a partially expanded result.
  • URL brackets, a port, a CIDR prefix length, and an interface zone identifier are surrounding syntax rather than part of the 128-bit IPv6 value. Convert the address itself and handle those components separately.

Common questions

Does compressing an IPv6 address lose information?

No. Leading zeroes inside a hextet do not affect its 16-bit value, and the number of zero hextets represented by `::` is recovered by filling the address to eight hextets. Conversion is reversible for the numeric address. It does not preserve cosmetic choices such as uppercase letters or the original placement of optional zero suppression.

Will every system display the same compressed spelling?

No. IPv6 permits multiple equivalent textual spellings, while RFC 5952 recommends a canonical choice: lowercase hexadecimal, no unnecessary leading zeroes, and `::` for the longest eligible zero run, using the first run when lengths tie. Software that does not canonicalize may display another valid spelling. Expand both addresses and compare all eight hextets when equality is in doubt.

References and verification

The example and behavioral notes were checked against the browser implementation. Standards and primary references below define the relevant format, formula, or platform behavior.

Related Tools