← All tools

IPv6 Address Expander and Collapser

Expand an IPv6 address to all eight groups or collapse it to the canonical short form: one address or a list of up to 1,000.

One IPv6 address per line, up to 1,000. A prefix length such as /64 is kept.
Try:

How an IPv6 address is expanded and compressed

An IPv6 address is 128 bits, written as eight groups of four hexadecimal digits. The expanded form shows every digit. The compressed form leaves out what can be restored without guessing, and it is the form that software prints and people type.

2001:0db8:0000:0000:0000:8a2e:0370:7334   expanded
2001:db8::8a2e:370:7334                   compressed

The rules of the short form (RFC 5952)

  • Leading zeros of a group are dropped: 0db8 becomes db8, 0000 becomes 0.
  • The longest run of two or more zero groups is replaced by ::. When two runs are equally long, the first one is replaced.
  • A single zero group stays 0: it is not shortened to ::.
  • Letters are written in lower case.

Expand and compress IPv6 in Python and PHP

# Python
import ipaddress
a = ipaddress.ip_address('2001:db8::8a2e:370:7334')
a.exploded     # 2001:0db8:0000:0000:0000:8a2e:0370:7334
a.compressed   # 2001:db8::8a2e:370:7334

// PHP
inet_ntop(inet_pton('2001:0db8:0000:0000:0000:8a2e:0370:7334'));   // 2001:db8::8a2e:370:7334
implode(':', str_split(bin2hex(inet_pton('2001:db8::8a2e:370:7334')), 4));   // 2001:0db8:0000:0000:0000:8a2e:0370:7334
FAQ

Frequently asked questions

What is the expanded form of an IPv6 address?

The full notation: eight groups of exactly four hexadecimal digits separated by colons, 39 characters in all, for example 2001:0db8:0000:0000:0000:8a2e:0370:7334. It is handy where addresses must line up or be compared as text: in sorted lists, in database keys, in reverse DNS zones.

Why can :: appear only once in an address?

:: stands for “as many zero groups as it takes to make eight”. With one gap the number of missing groups is known; with two it would be impossible to tell how many zeros belong to each, so 2001::25de::cade is not a valid address.

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

Yes. Hexadecimal digits mean the same in either case, and leading zeros change nothing either. RFC 5952 recommends lower case, so that one address is always written one way; this tool follows it.

How are IPv4-mapped IPv6 addresses written?

Addresses of the form ::ffff:192.0.2.128 carry an IPv4 address in their last 32 bits. The short form keeps that tail in dotted notation, as RFC 5952 recommends; the expanded form shows it as two hexadecimal groups, c000:0280. The embedded IPv4 address is shown on a line of its own.

What happens to a prefix length such as /64?

It is kept: 2001:db8::/32 expands to 2001:0db8:0000:0000:0000:0000:0000:0000/32. The address itself is not changed or rounded to the start of the network; for the range of a prefix use the CIDR to IP range tool.

Is the address I enter sent to your server?

No. The conversion runs entirely in your browser: nothing is transmitted or stored.