Punycode is the bootstring encoding that represents a Unicode string using only the letters, digits and hyphen allowed in DNS host names, which makes it the technical bridge for internationalized domain names on the Internet. Defined in RFC 3492, it converts a label such as bücher into bcher-kva, and the IDNA protocol then adds the ACE prefix `xn--` so that the label stored in the DNS becomes xn--bcher-kva.
Within domain names, Punycode is a transport format, not a display format. Users type and read the Unicode form, while registries, name servers and certificates handle the ASCII-compatible encoding. Understanding both forms matters for registration, email, TLS certificates and phishing defense.
How the Punycode algorithm encodes a label
Punycode encodes a label in two parts: the basic code points copied unchanged, followed by a compact description of where the non-ASCII characters belong. In bücher, the ASCII letters bcher are copied first, a hyphen separates them from the rest, and the trailing kva encodes the insertion of ü at position two.
The second part uses generalized variable-length integers in base 36, the digits being a to z and 0 to 9. Each integer is a delta that tells the decoder how far to advance through a combined state of code point value and insertion position. An adaptive bias adjusts the thresholds after each character, so text from a single script, where code points cluster closely, produces short output.
The algorithm is reversible and unique: every Unicode string maps to exactly one Punycode string, and decoding restores the original. The table shows how its fixed parameters, defined in RFC 3492, shape the output.
| Parameter | Value | Role |
|---|---|---|
| Base | 36 | Digit alphabet a-z and 0-9 |
| Initial n | 128 | First non-ASCII code point |
| Initial bias | 72 | Starting threshold adjustment |
| Damp | 700 | Scales the first bias update |
| Delimiter | Hyphen | Separates basic and encoded parts |
Punycode inside the IDNA framework
Punycode alone does not define which characters are valid in domain names; that is the job of IDNA, the Internationalizing Domain Names in Applications framework. IDNA validates and normalizes each label, then applies Punycode and adds the xn-- prefix. The resulting form is called an A-label, while the Unicode form is a U-label.
Two generations of IDNA coexist, and their differences still cause inconsistent behavior between browsers, libraries and registries.
| Aspect | IDNA2003 | IDNA2008 |
|---|---|---|
| Specifications | RFC 3490 and RFC 3491 | RFC 5890 to RFC 5894 |
| Character rules | Nameprep mapping table | Per-code-point derived property |
| German ß | Mapped to ss | Valid, encoded distinctly |
| Case folding | Built into the protocol | Left to application mapping |
| Unicode version | Fixed at Unicode 3.2 | Derived for newer versions |
Many browsers follow Unicode Technical Standard 46, which provides a compatibility mapping between the two generations. As a result, a name containing ß may resolve to different A-labels in different software, which is a known source of lookup mismatches.
Length limits and encoded examples
Every A-label must respect the DNS limit of 63 octets per label and 253 characters for the whole name. Because Punycode adds the four-character prefix and encoding overhead, a Unicode label usually has a much lower character limit than its ASCII equivalent, depending on the script.
The examples below show how the same principle produces different lengths across scripts.
| U-label | A-label | Script |
|---|---|---|
bücher | xn--bcher-kva | Latin with diacritic |
münchen | xn--mnchen-3ya | Latin with diacritic |
пример | xn--e1afmkfd | Cyrillic |
例え | xn--r8jz45g | Japanese |
испытание | xn--80akhbyknj4f | Cyrillic |
Labels written entirely in a non-Latin script contain no basic code points, so the A-label has no leading ASCII part and no delimiter hyphen before the encoded digits. Top-level domains such as .рф exist in the root zone as xn--p1ai.
Where Punycode appears in practice
Punycode appears wherever a system can only carry ASCII host names. Registrars submit A-labels to the registry through EPP, zone files store them, and WHOIS or RDAP outputs usually show both forms. TLS certificates list the A-label in the subject alternative name, because certificate validation compares ASCII strings.
Email is a special case. The domain part of an address can be converted to an A-label, but the local part cannot, so fully internationalized addresses rely on SMTPUTF8 extensions rather than Punycode. Web servers, proxies and logs often record the encoded form, which is why administrators should be able to read and convert A-labels quickly. Conversion must always run through a complete IDNA library rather than a bare Punycode routine, because skipping normalization and validation can produce an A-label that registries reject or that resolves differently in browsers.
Homograph attacks and display policy
The main security risk linked to Punycode is the IDN homograph attack, in which a domain uses look-alike characters from another script to imitate a trusted name. A label made of Cyrillic а and о can look identical to a Latin brand while having an unrelated A-label.
Browsers therefore apply display policies: they show the Unicode form only when the label passes script-mixing and confusable checks, and otherwise display the raw xn-- form as a warning signal. Registries add defenses through script restrictions and variant bundling. The table summarizes the layers of protection.
| Layer | Measure | Limitation |
|---|---|---|
| Registry | One script per label, variant blocking | Policies differ by TLD |
| Browser | Show A-label for mixed scripts | Whole-script spoofs may pass |
| Certificate authority | Review of high-risk names | Not universally applied |
| Organization | Defensive registration of look-alikes | Cost grows with variants |
A frequent mistake is treating the visible Unicode name as proof of identity. Comparing A-labels, not rendered text, is the reliable test in security tooling and allow lists.
A non-technical view
The system that finds websites was built to understand only basic English letters, digits and the hyphen. Punycode is a translation trick that lets names written with accents, Cyrillic, Arabic or Chinese characters travel through that old system.
A name like bücher is quietly rewritten as xn--bcher-kva behind the scenes, and the browser turns it back into readable text for the visitor. The key point is that the same address has two spellings: one for people and one for machines.
A concrete example
A bookshop chain in Munich registers bücher-shop under the German country domain to match how customers write its name. The registrar submits the A-label xn--bcher-shop-9db to the registry, and the IT team configures the web server, the CDN and the redirect rules using that encoded form.
When the team requests a TLS certificate, the certificate authority issues it for the A-label, and browsers display the friendly Unicode name in the address bar because the label uses a single script. The team also registers the plain variant buecher-shop and redirects it, since some customers still type the transliterated spelling.
The result is one storefront reachable by both spellings, with monitoring that alerts on any newly registered look-alike labels.