IPv6 Compressor / Expander
Type or paste any IPv6 address to see its compressed and expanded forms side by side. The expander fills in leading zeros and reinstates omitted groups. The compressor applies RFC 5952 rules: omit leading zeros and replace the longest run of zero groups with ::.
Reviewed by the ToolNestr Editorial Team — July 2026
Enter an IPv6 address
—
—
How IPv6 compression and expansion work
IPv6 addresses are 128 bits long, written as eight groups of four hexadecimal digits separated by colons. RFC 4291 defines the basic format, and RFC 5952 defines the canonical text representation. Because a full address like 2001:0db8:0000:0000:0000:0000:0000:0001 is cumbersome, two compression techniques were introduced: leading zero omission and double colon replacement.
Leading zero omission is straightforward. In each 16-bit group, any leading zeros can be removed. The group 0db8 becomes db8, 0001 becomes 1, and 0000 becomes 0. This alone typically halves the length of the address. The double colon (::) rule is more complex: you may replace the longest contiguous run of all-zero groups with a single ::. For example, 2001:0db8:0000:0000:0000:0000:0000:0001 becomes 2001:db8::1. Only one :: is permitted per address to avoid ambiguity when expanding.
The expansion process is the reverse. Given a compressed address like 2001:db8::1, the expander splits the string on colons, counts the groups, and determines how many zero groups the :: represents by subtracting from 8. It then inserts that many 0000 groups at the :: position, pads every group to 4 hex digits with leading zeros, and joins them with colons. The result is the canonical full form: 2001:0db8:0000:0000:0000:0000:0000:0001.
RFC 5952 rules for canonical representation
RFC 5952 establishes a canonical text representation for IPv6 addresses to ensure consistency across tools and implementations. The rules are designed to produce a single unambiguous representation for every valid IPv6 address. The first rule is that hexadecimal digits must use lowercase. Uppercase representations like 2001:DB8::1 are valid but not canonical. All tools should accept uppercase input but produce lowercase output.
The second rule governs leading zero suppression. Each 16-bit group should have all leading zeros removed. The group 0000 becomes 0, 00a0 becomes a0, and 0001 becomes 1. The third and most complex rule handles the double colon. When compressing, replace the longest contiguous run of all-zero groups with ::. If there are multiple runs of equal length, replace the leftmost one. Only one :: is ever used. These rules ensure that the compression is deterministic and reversible.
Common IPv6 address types and their formats
Unspecified address (::)
The address :: (all zeros) is used as a source address during duplicate address detection and in DHCPv6 solicit messages. It is never assigned to an interface as a valid destination.
Loopback address (::1)
The address ::1 is the IPv6 loopback address, equivalent to 127.0.0.1 in IPv4. Packets sent to ::1 are looped back to the local host and never leave the interface. It is used for testing and local communication.
Global unicast (2000::/3)
Global unicast addresses start with 2000::/3 (first 3 bits are 001) and are routable on the internet. A typical global unicast prefix is 2001:db8::/32, which is reserved for documentation (RFC 3849).
Link-local (fe80::/10)
Link-local addresses (fe80::/10) are automatically configured on every IPv6 interface and are only valid on the local link. They are used for neighbor discovery (NDP) and routing protocols like OSPFv3 and RIPng.
Practical tips for working with IPv6 addresses
When copying IPv6 addresses from configuration files, be aware that some systems use uppercase hex digits while others use lowercase. This calculator normalizes all input to lowercase for consistency. If you are entering an IPv6 address in a URL, enclose it in square brackets: http://[2001:db8::1]:8080/path. Without the brackets, the colon after the address is ambiguous with the port separator.
For network configuration, most operating systems accept IPv6 addresses in any valid format (compressed or expanded). However, when writing scripts that parse IPv6 addresses, always normalize to the canonical form first. This calculator can help verify that two addresses are equivalent even if they appear different. For example, 2001:db8::1, 2001:0db8::1, and 2001:0db8:0000:0000:0000:0000:0000:0001 all represent the same address.
Frequently asked questions
What is IPv6 address compression?
IPv6 address compression (RFC 5952) reduces the length of an IPv6 address by two methods: omitting leading zeros in each 16-bit group, and replacing the longest contiguous run of all-zero groups with a double colon (::). Only one :: per address is allowed. For example, 2001:0db8:0000:0000:0000:0000:0000:0001 compresses to 2001:db8::1.
What is the :: rule in IPv6 compression?
The :: (double colon) replaces a contiguous block of zero groups. RFC 5952 specifies that you must replace the longest run of consecutive zero groups. If there are multiple runs of the same length, replace the leftmost one. Only one :: is allowed per address, so if there are multiple zero runs, the longest one is replaced.
Can leading zeros always be omitted?
Yes, in each 16-bit hexadecimal group, leading zeros can be omitted entirely. For example, 00a0 becomes a0, 0001 becomes 1, and 0000 becomes 0. However, RFC 5952 recommends that the single zero group left after omitting zeros from 0000 should be written as 0, not omitted. This is the canonical compressed form.
How do I expand an IPv6 address with ::?
To expand, count the number of groups present. Subtract from 8 to determine how many zero groups :: represents. Insert that many 0000 groups. Then pad each remaining group to 4 hex digits by adding leading zeros. For example, ::1 expands to 0000:0000:0000:0000:0000:0000:0000:0001.
Is there a difference between :: and ::1?
Yes. :: is the unspecified address (all zeros), equivalent to 0:0:0:0:0:0:0:0. It is used in DHCPv6 and as a source address during duplicate address detection. ::1 is the loopback address, equivalent to 127.0.0.1 in IPv4, used for testing the local protocol stack.
Why does my browser show IPv6 in a different format?
When you type an IPv6 address in a browser URL bar, you must enclose it in square brackets, e.g. http://[2001:db8::1]:8080/. This is required by RFC 3986 to distinguish the colon separators from the port number separator. The address inside the brackets can be in any valid format.
What is the canonical IPv6 text representation?
RFC 5952 defines the canonical text representation: lowercase hex digits, leading zeros omitted, longest zero run replaced with ::, and only one ::. For consistent results, all tools should produce and accept this canonical form. This calculator follows the RFC 5952 specification.
Are there any limitations to compression?
The main limitation is that only the longest zero run can be compressed. If an address has two zero runs of equal length (e.g. 2001:0000:0000:0001:0000:0000:0000:0002), only the rightmost or longest is replaced based on RFC 5952 rules. The other zero run remains as explicit zeros. This prevents ambiguity when expanding.