Checking equivalent compressed and expanded IPv6 spellings
One IPv6 address can be written in several ways. This guide compares a fully expanded spelling with its zero-compressed form and shows that the containing prefix depends only on the address value.
Two spellings, one value
The expanded address 2001:0db8:0001:0002:0000:0000:0000:1234 and the compressed address 2001:db8:1:2::1234 look different, yet both stand for the same 128-bit number. Under a prefix of 64, both give the network 2001:db8:1:2::, and both report 18446744073709551616 addresses in the block. The calculator parses the text into bits first, so the spelling plays no role after that step. This matters whenever addresses are compared by eye or by text matching, because two correct spellings can fail a string comparison while being equal as numbers. The safe comparison is always on the parsed value. The example also shows how much shorter the compressed form is: 17 characters against 39 for the expanded text, which is why compressed spellings dominate in configuration files, while the expanded form is still useful when you need to see each group aligned in a table.
The compression rules
RFC 4291 allows two shortcuts. Leading zeros in a group may be dropped, so 0db8 becomes db8 and 0001 becomes 1. One run of consecutive all-zero groups may be replaced by a double colon, which may appear only once in an address. In the example, the three groups of 0000 between 0002 and 1234 collapse to the double colon, giving 2001:db8:1:2::1234. If the address had two separate runs of zeros, only one could be compressed, since two double colons would leave the length ambiguous. A string with two of them, such as 2001:db8::1::2, is invalid.
The recommended text form
RFC 5952 describes a single preferred way to write an address, so that documents and logs stay consistent. It asks for lowercase hex digits, no leading zeros in a group, and compression of the longest run of zero groups, using the first run when two are tied, and never compressing a single zero group. Under those rules, 2001:0DB8:0001:0002:0000:0000:0000:1234 is written 2001:db8:1:2::1234. The calculator outputs its network in that style, which is why the expanded input yields a compact network string. Input does not have to follow the recommendation, since the parser accepts valid variations.
Case, zeros and alternative forms
Hex digits are not case sensitive, so 2001:DB8:1:2::1234 is the same address as the lowercase form. Entering the uppercase text with prefix 64 gives the same network and count. An address can also be written 2001:db8:1:2:0:0:0:1234, with the zero groups shown as single zeros, and it is still the same value. A compressed form can also leave a different number of groups hidden: 2001:db8::1 hides five groups, while 2001:db8:0:0:1:: hides a different run. When you read a compressed address, count the groups that are written and subtract from eight to find how many zero groups the double colon stands for.
Comparing prefixes with different spellings
The containing prefix follows from the value. With prefix 48, both spellings of the example give 2001:db8:1::, because the first three groups are 2001, 0db8 and 0001, and the fourth group onward is cleared. Prefix 64 keeps 0002 as well, so the network is 2001:db8:1:2::. A check that the network outputs match is a convenient way to confirm that two spellings are one address: if the networks differ for any prefix, the values differ. If they match for all prefixes up to 128, the addresses are identical. In practice, comparing the network at /128 would be the strictest test.
Zone identifiers are outside this input
Link-local addresses are often written with a zone identifier after a percent sign, such as fe80::1%eth0, where the label names the interface that makes the address unambiguous on a host. That suffix is not part of the 128-bit address, and this calculator expects an address without one. If an address copied from a command output contains a percent sign, remove the suffix before entering it. The remaining address is parsed as usual. The suffix has local meaning only, and the same link-local address can legitimately be used on several interfaces of one machine. That is why the identifier is written in the text but never stored in the 128 bits, and why an address with a zone suffix has no single containing prefix that is meaningful beyond the host that produced it.
Where spelling differences cause trouble
Mismatched spellings tend to break searches, access lists compared as text, spreadsheet lookups and deduplication. A log that records 2001:db8:1:2::1234 will not match a search for the expanded form unless the search tool normalizes first. Sorting text is another trap, because sorting by characters does not follow numerical order for addresses with different group lengths. The remedy is the same in each case: parse to a canonical form, preferably the RFC 5952 text or the 128-bit integer, and compare that. Doing so before storing addresses prevents duplicate entries for one address.
What parsing and matching establish
Successful parsing means that the text is a syntactically valid address, and matching prefix outputs mean two spellings share a value. Neither fact shows that the address is assigned to a device, routed on any network or reachable. This worksheet performs bit arithmetic on documentation addresses from 2001:db8::/32, reserved by RFC 3849, and it touches no network. Use it to normalize and compare text. Questions of allocation, routing and connectivity need the network owner, the routing system or a test on the actual network.
Writing an address for a document
When you publish an address in a plan, a ticket or a log, choose one spelling and keep it. The RFC 5952 form is a good default because a single rule set produces a single text for each address, which makes searching and diffing reliable. For the example, write 2001:db8:1:2::1234 each time. Put the prefix length after a slash, as in 2001:db8:1:2::/64 for the network. Avoid mixing in the expanded form in the same document, except in a table that teaches how compression works. If a tool shows you an address in another style, convert it before pasting, so a later reader does not wonder whether two entries refer to different hosts.
Reproduce the checks
Expanded spelling
Open the Ipv6 Subnet Calculator and enter:
- IP address
2001:0db8:0001:0002:0000:0000:0000:1234- Prefix length
64
Expected output:
Network
2001:db8:1:2::Address count
18446744073709551616The output normalizes the network spelling.
Compressed spelling
Open the Ipv6 Subnet Calculator and enter:
- IP address
2001:db8:1:2::1234- Prefix length
64
Expected output:
Network
2001:db8:1:2::Address count
18446744073709551616The exact address count is retained as an integer string.
References and implementation scope
The examples describe the behavior of the linked Computandum tools. A successful local check does not establish that another application accepts the same format or applies the same limits.
Sources
- Primary definition and convention reference ↗ · 2026-10-08