Skip to content
LookupOwl

IPv6 address compressor

Shorten an IPv6 address to its one canonical form, as RFC 5952 defines it.

One per line. We shorten each one the standard way (RFC 5952).

Results for 2001:0db8:0000:0000:0000:ff00:0042:8329

Formatted just now

JSON

IPv6 address

Here it is, tidied

The short form is what you should paste into configs (RFC 5952). The long form is handy for sorting and spotting typos.

Result
2001:db8::ff00:42:8329
Already canonical
No

Leading zeros were removed from groups (RFC 5952 section 4.1).

Other forms
Structured result (JSON) · 489 B
{
  "items": [
    {
      "input": "2001:0db8:0000:0000:0000:ff00:0042:8329",
      "ok": true,
      "result": "2001:db8::ff00:42:8329",
      "canonical": false,
      "changes": [
        "Leading zeros were removed from groups (RFC 5952 section 4.1).",
        "A run of zero groups was replaced with \"::\" (RFC 5952 section 4.2)."
      ],
      "compressed": "2001:db8::ff00:42:8329"
    }
  ],
  "totals": {
    "items": 1,
    "ok": 1,
    "failed": 0
  },
  "truncated": false
}

What compression does

Compression writes an IPv6 address in its shortest standard form. Drop the leading zeros in each group, then replace the longest run of all-zero groups with ::. That turns 2001:0db8:0000:0000:0000:ff00:0042:8329 into 2001:db8::ff00:42:8329. An IPv6 address has eight groups of four hex digits, and several short forms of the same address are legal. RFC 5952 picks one, so logs, databases and people agree on a single text for each address.

How to use it

  1. Paste addressesOne per line, up to 1,000 (commas and spaces also separate them). Prefix lengths (/64), zone IDs (%eth0, which name a network interface), square brackets with a port and URL hosts are accepted and left in place around the address.
  2. Copy the canonical formOne address shows its short form and whether it was already canonical, with the first reason it changed. The JSON lists every change. Several addresses go into a table next to what you typed.
  3. Use it for comparisonsNormalise addresses before you compare, deduplicate or store them as text. Two strings are the same address only if their canonical forms match.

The RFC 5952 rules

  1. Leading zeros in a group are removed, but a group of all zeros is written as a single 0.
  2. :: replaces the longest run of consecutive zero groups, and appears at most once.
  3. If two runs tie, the first is replaced.
  4. :: is never used for a single zero group. Write 0 instead.
  5. Hex digits are lowercase.
InputCanonicalWhy
2001:0DB8:0000:0000:0000:FF00:0042:83292001:db8::ff00:42:8329Lowercase, leading zeros dropped, longest run compressed
2001:db8:0:0:1:0:0:12001:db8::1:0:0:1Two equal runs: the first one wins
2001:0:0:1:0:0:0:12001:0:0:1::1The longer run (three groups) wins
2001:db8:0:1:1:1:1:12001:db8:0:1:1:1:1:1A single zero group is not compressed
::ffff:102:304::ffff:1.2.3.4Special case: IPv4-mapped addresses keep a dotted ending

The last row follows RFC 5952 section 5, which recommends a dotted ending for addresses that carry an IPv4 address behind a well-known prefix. This tool applies it to IPv4-mapped addresses only (an IPv4 address carried inside an IPv6 one), as Go and recent versions of Python do. Every other address is written in hex. The all-hex spelling of a mapped address is shown under Other forms and in the JSON as compressedHex.

Why other tools disagree

  • Older software compresses the first run, not the longest. Libraries and devices written before RFC 5952 (2010) can produce valid but non-canonical text, for example 2001:0:0:1:0:0:0:1 written as 2001::1:0:0:0:1 instead of 2001:0:0:1::1.
  • A single zero group compressed. Some tools write 2001:db8::1:1:1:1:1 for an address with one zero group. It is valid, but RFC 5952 forbids it.
  • Uppercase hex. Legal when you type it, but not canonical in output.
  • Invalid input. More than one ::, a group longer than four digits, more than eight groups or a stray character gets an error that says what is wrong, and where when it can.
  • Dotted endings. Only IPv4-mapped addresses keep one. Anything else with a dotted tail, such as 64:ff9b::8.8.8.8, comes out in hex as 64:ff9b::808:808.

How the compressor works

The address is parsed into eight 16-bit values, validated, and written out again by the five rules above. Finding the longest run of zero groups takes a single pass. The conversion runs on our server. The addresses are not written to logs and are held in memory for at most a day. On the website, Google Analytics also records what you enter, as the privacy policy explains.

The standards are RFC 4291 section 2.2 (the text forms of an address) and RFC 5952 (the recommended representation). Zone IDs come from RFC 4007, and square brackets around an address in a URL from RFC 3986.

Questions people ask

How do I shorten an IPv6 address?

Drop the leading zeros in each group, then replace the longest run of all-zero groups with ::. For example, 2001:0db8:0000:0000:0000:0000:0000:0001 becomes 2001:db8::1. Write the hex digits in lowercase too. The tool applies the standard rules to every address you paste and shows the result.

Can I use :: more than once?

No, an address can contain :: only once. Two double colons would make the address ambiguous, because nobody could tell how many zero groups each one stands for. If an address has two separate runs of zeros, only the longest is replaced and the other keeps its zeros.

Why is my address not compressed further?

Either it has no run of two or more zero groups, or it is already canonical. A single zero group is written as 0 and never as ::, so 2001:db8:0:1:1:1:1:1 stays as it is. The tool marks addresses that need no change.

Are 2001:db8::1 and 2001:0db8:0:0:0:0:0:1 the same address?

Yes. They are two ways of writing the same 128-bit number, and every network stack treats them as one address. The trouble starts in text: a plain string comparison, a database lookup or a log search sees two different strings. Store and compare the canonical form and the problem goes away.

Does it keep a port or prefix?

Yes. Prefix lengths, zone IDs, brackets with ports and URL hosts are kept around the compressed address, and only the address itself is rewritten. For example, [2001:DB8:0:0:0:0:0:1]:8080 becomes [2001:db8::1]:8080, and 2001:0db8:0:0:0:0:0:1/64 becomes 2001:db8::1/64. You can paste a whole URL or a prefix and get it back tidied.

Why does ::ffff:1.2.3.4 still have dots in it?

It is an IPv4-mapped address, and RFC 5952 section 5 recommends a dotted ending for addresses like it, so this tool keeps one. The all-hex spelling, ::ffff:102:304, is the same address. Other addresses that you type with a dotted ending are written out in hex.

How do I expand a compressed address?

Use the IPv6 expand tool, which writes out all 32 hex digits again. It also gives you the form without leading zeros, the binary form and the ip6.arpa name that reverse DNS uses, so it is handy for sorting, comparing and building PTR records.

Are the addresses I paste stored anywhere?

Not in our logs. The compression runs on our server, whether you use the web page, the API or an AI assistant, and the addresses are held in memory for at most a day. On the website, Google Analytics also records what you enter. The privacy policy has the details.

Use it from AI, the API or the command line

Every LookupOwl tool is also a free API and an MCP tool, with no key and no account. This one is ipv6_format. Please be kind to the rate limits.

curl
curl "https://lookupowl.com/api/v1/tools/ipv6-format?q=2001%3A0db8%3A0000%3A0000%3A0000%3Aff00%3A0042%3A8329"
MCP
claude mcp add --transport http lookupowl https://lookupowl.com/mcp