A full IPv6 address is eight groups of four hex digits, which is a lot to read or type. RFC 5952 defines one canonical short form for every address, so the same value always compresses the same way. The three rules are: lowercase every group, drop the leading zeros inside each group, and collapse the longest run of all-zero groups to ::. The IPv6 compress tool applies all three for you, but they are worth knowing.
Rule one: lowercase
Hex digits a through f must be lowercase. 2001:0DB8 is written 2001:0db8. Uppercase is still a valid address, but it is not the canonical form, and mixing cases makes addresses harder to compare by eye or with a simple string match.
Rule two: strip leading zeros
Inside each group, remove the zeros at the front. A group keeps at least one digit, so a group of 0000 becomes 0, not empty.
0db8 → db8
0042 → 42
0000 → 0
ff00 → ff00 (no leading zeros to drop)
This rule applies per group and is independent of the :: rule below.
Rule three: collapse the longest zero run
This is the one that does the real shortening. Find the longest run of consecutive groups that are entirely zero, and replace that whole run with ::. Take the documentation address:
2001:0db8:0000:0000:0000:ff00:0042:8329
After lowercasing and stripping leading zeros, the groups are 2001 db8 0 0 0 ff00 42 8329. The longest zero run is the three groups in the middle, so they collapse:
2001:db8::ff00:42:8329
The :: may appear only once in an address. If you used it twice, a reader could not work out how many zero groups each one replaced.
The tie rule
When two separate zero runs are the same length, the leftmost one is collapsed. Consider:
2001:0:0:1:0:0:0:1
There is a run of two zeros and a run of three. The run of three is strictly longer, so it wins regardless of position, giving 2001:0:0:1::1. The tie rule only matters when the runs are exactly equal in length; then you take the one nearer the start.
A single zero stays a zero
A lone zero group is never written as ::. The shorthand is reserved for runs of two or more. So 2001:db8:0:1:1:1:1:1 keeps its 0 and does not compress further. This is a common point of confusion, because some tools wrongly collapse a single zero.
Checking your work
The safest way to confirm a compression is to expand it again and compare. If 2001:db8::ff00:42:8329 expands back to 2001:0db8:0000:0000:0000:ff00:0042:8329, the short form is correct. The method for that is in how to expand an IPv6 address. Compression and expansion never change the underlying 128-bit value, so the two forms are interchangeable anywhere an address is accepted.
If the address you are compressing came from an IPv4 address, for instance an ::ffff: mapped form, the same rules apply; see how to convert IPv4 to IPv6 for how those forms are built.
Do it in one step
The rules are simple, but applying them under pressure invites mistakes, especially the tie rule and the single-zero exception. Paste any IPv6 address into the IPv6 compress tool and it returns the canonical RFC 5952 form, with the full expansion shown beside it so you can verify the result yourself.