ipv6Unpack() function

Expands an IPv6 address to its full eight-group, four-digit form.

Signature:

export declare function ipv6Unpack(ip: string): string;

Parameters

Parameter

Type

Description

ip

string

an IPv6 address, compressed or not

Returns:

string

The 39-character canonical form, e.g. 2001:db8::1 becomes 2001:0db8:0000:0000:0000:0000:0000:0001.

Exceptions

TypeError if the address contains more than one ::.

Remarks

The inverse of ipv6Pack(), and the form ipToInt() needs before it can read the groups as bytes. An input already IPV6_MAX_STR_LEN characters long is returned untouched on the assumption it is already expanded.

Dots are rewritten to colons first, so the IPv4-mapped form ::ffff:1.2.3.4 expands without failing — but its trailing octets are treated as hex groups, not as a dotted quad, so the result is not the address a reader would expect. Convert mapped addresses yourself if the exact value matters.

Read this page as plain markdown — no HTML, no navigation. For pasting into an LLM, or for an agent to fetch.