DNSVerdict

IDN and punycode explained: xn-- domains, safely

Published · Updated

DNS carries only ASCII letters, digits and hyphens in host names, so a domain with other letters, such as münchen.de, is stored as an xn-- label made with Punycode: xn--mnchen-3ya.de. The Unicode form is the U-label, the xn-- form is the A-label, and DNS records, zone files and lookups use the A-label. Convert either way with the punycode converter.

DNSVerdict’s Punycode tool converts a whole domain name in both directions, label by label, in your browser and warns about length limits and lookalike letters.

U-label and A-label

RFC 5890 §2.3.2.1 defines two forms of the same label. A U-label is an IDNA-valid Unicode string in Normalization Form C that contains at least one non-ASCII character. An A-label is its ASCII-compatible form: the prefix xn-- followed by Punycode output. The same section limits the Punycode part to 59 ASCII characters, which keeps the whole A-label inside the DNS limit of 63 octets per label (RFC 5890 §2.3.1). A U-label can therefore be valid in length as Unicode and still be too long once encoded, so check the encoded form.

FormExampleWhere you see it
U-labelmünchenAddress bar, mail clients, web pages
A-labelxn--mnchen-3yaDNS records, zone files, certificates, logs
LDH labelexampleOrdinary ASCII names

Punycode in one paragraph

Punycode, RFC 3492, “uniquely and reversibly transforms a Unicode string into an ASCII string”. It copies the ASCII characters first, adds a hyphen (U+002D) as the delimiter, then appends a base-36 encoding of where the other characters go and what they are (§5). That is why münchen becomes mnchen-3ya: mnchen is the ASCII part, 3ya encodes the ü and its position. A label with no ASCII characters has no delimiter. Punycode is only the encoding. Whether a label is allowed at all is decided by IDNA.

IDNA2008 and UTS #46

IDNA2008 is a set of RFCs. RFC 5890 gives the definitions, RFC 5891 the protocol, and RFC 5892 the table of allowed code points. Registries must accept only the exact string requested, in NFC, “free of any mappings or local adjustments” (RFC 5891 §4.1). A lookup application converts the user’s input to NFC, optionally after mapping, and rejects labels that break the rules before it queries DNS (RFC 5891 §5.2, §5.4).

UTS #46 from the Unicode Consortium is a compatibility layer that browsers use to deal with what people actually type, such as uppercase letters or full-width characters. It maps input first (case folding and similar), then validates, and it accepts some symbols and emoji that IDNA2008 disallows. IDNA2003 and IDNA2008 treat four characters differently, which UTS #46 calls deviations (§1.3.2): ß (U+00DF), ς (U+03C2), and the joiners ZWNJ (U+200C) and ZWJ (U+200D). IDNA2008 treats ß and ς as valid (RFC 5892 §2.6) and the joiners as valid only in context (RFC 5892 Appendix A.1 and A.2). The older IDNA2003 mapped ß to ss and ς to σ, so faß.de and fass.de were the same name.

UTS #46 has two modes. Transitional processing maps the four deviation characters as IDNA2003 did; it is deprecated, and UTS #46 §2 says the transition is complete and major implementations use nontransitional processing. Nontransitional processing keeps them and is, in the specification’s words, “fully compatible with IDNA2008”. The WHATWG URL Standard, which browsers follow, calls ToASCII with Transitional_Processing set to false, CheckJoiners and CheckBidi true, and CheckHyphens and UseSTD3ASCIIRules following its strictness flag. Its own example: faß.example becomes xn--fa-hia.example, not fass.example.

The practical results:

Lookalike domains and when browsers show punycode

Many scripts contain letters that look identical to Latin ones. Cyrillic а is not Latin a. An attacker can register an IDN that reads as apple.com in the address bar. This is a homograph attack. Browsers respond by deciding for each label whether to display Unicode or the xn-- form.

Chromium’s IDN policy checks each label in turn and shows punycode if a check fails. Among them: the label does not convert cleanly, uses characters outside the allowed identifier set, mixes Latin, Cyrillic and Greek, mixes numbering systems, includes invisible characters, is made entirely of whole-script confusables under a TLD that does not fit that script, or has a skeleton that matches a top domain. Its own example shows googlé.com as punycode and the all-Cyrillic аррӏе.com as punycode. A label that passes every check is shown in Unicode.

Firefox also shows punycode for labels it considers suspicious. Mozilla’s IDN display policy is on its IDN Display Algorithm page; we could not load it when writing this guide, so read it directly for the current rules.

Two consequences. First, seeing xn-- in the address bar does not mean the site is hostile; it means the browser did not trust the Unicode form. Second, a Unicode form in the bar does not prove safety either. If you register a brand, register the lookalikes that matter to you. Chromium’s page also suggests redirecting defensive registrations to your main domain with a 301 or 302. Use the domain availability tool to check them and the RDAP lookup to see who holds a suspicious one.

What DNS actually stores

DNS does not know about Unicode. RFC 2181 §11 allows labels of 1 to 63 octets and says that “any binary string whatever can be used as the label”. Nothing stops a zone from holding raw UTF-8 bytes in a label. But IDNA clients look up the A-label, so a raw UTF-8 record is a different name that nobody asks for. Always publish the A-label.

Putting an IDN in DNS records

Write every name in the A-label form, including in the data of the record:

xn--mnchen-3ya.de.        3600 IN A     192.0.2.10
www.xn--mnchen-3ya.de.    3600 IN CNAME xn--mnchen-3ya.de.
xn--mnchen-3ya.de.        3600 IN MX    10 mail.xn--mnchen-3ya.de.

Most DNS control panels accept the Unicode form and convert it for you. If one does not, convert the name with the punycode converter and enter the xn-- form. To see what is published, query the A-label with the DNS lookup; the tool shows both forms when you enter a Unicode name. Only the labels with non-ASCII characters change: in mail.münchen.de, mail and de stay as they are.

IDN in email

An address can have a non-ASCII local part and domain only if both sides support SMTPUTF8, defined in RFC 6531. The server advertises the SMTPUTF8 keyword (§3.1), and the client adds the parameter to MAIL when the message needs it (§3.4). The domain part is still resolved through DNS as an A-label (§3.2), and clients may send either form. Without SMTPUTF8 support, domains SHOULD be in A-label form (§3.7), and before the server’s EHLO response a client may send only ASCII domains (§3.7.1). In practice, MX records and the SPF, DKIM and DMARC records of an IDN domain are all published under the A-label name.

FAQ

Is xn-- a sign of a scam? No. The prefix only marks a label stored in Punycode, as in xn--mnchen-3ya.de for münchen.de. Browsers show it when they refuse to display the Unicode form, for example for mixed scripts or when a name resembles a popular domain. Judge the site by the registered domain and its owner, not by the prefix alone.

Are ß and ss the same domain? No. With nontransitional processing, which the WHATWG URL Standard requires, faß.example converts to xn--fa-hia.example and fass.example stays a different name. Older IDNA2003 software mapped ß to ss. Both names can be registered separately, so register both if a brand uses the character.

Can I put Unicode directly in a zone file? Technically DNS allows any octets in a label (RFC 2181 §11), but IDNA clients look up the A-label, so a raw UTF-8 record is a different name that no browser will query. Publish the xn-- form. Most control panels convert for you; check the result by querying the A-label.

What is the longest IDN I can register? Each label’s A-label must fit in 63 octets, and the Punycode part after xn-- is capped at 59 ASCII characters (RFC 5890 §2.3.2.1). The full name is capped at 255 octets (RFC 2181 §11). Characters outside Latin take more Punycode space, so a label that is short in Unicode can still be too long.

Sources

Related: DNS record types explained, domain status codes, RDAP vs WHOIS, setting up MX records.

Tools used

xn-- Decoder: Punycode and IDN Domain ConverterDNS LookupRDAP Domain LookupDomain Availability Check