What Punycode is
This article takes about 4 minutes to read.
You type 日本.jp into the URL bar, yet xn--wgv71a.jp is displayed. What handles this conversion is Punycode.Traditionally, domain names could only use ASCII letters, digits, and hyphens. To handle internationalized domain names (IDN) that contain Japanese or emoji, Punycode was standardized as a mechanism for encoding non-ASCII characters into ASCII. You do not usually notice it, but it plays an important role behind the scenes in the browser's address bar and in security.
Definition
Punycode is a conversion algorithm that encodes Unicode strings using only a limited ASCII character set (a-z, 0-9, hyphen). Standardized in RFC 3492, it is the core technology of internationalized domain names (IDN, Internationalized Domain Names), and it lets domains that contain non-ASCII characters be handled by the existing DNS infrastructure. The converted result carries the prefix "xn--".
Why it is needed
When DNS (Domain Name System) was designed in the 1980s, domain names were limited to ASCII letters, digits, and hyphens. In the 2000s, the need to support the world's languages grew, but rewriting the existing DNS infrastructure was not realistic. So Punycode was devised as an "ASCII-compatible encoding (ACE, ASCII Compatible Encoding)", making possible a mechanism that passes ASCII strings to DNS while showing users the characters of the original language.
Conversion examples
| Original domain | Punycode form |
|---|---|
| 日本.jp | xn--wgv71a.jp |
| München.de | xn--mnchen-3ya.de |
| правда.рф | xn--80aafi6cg.xn--p1ai |
| 💩.la (emoji domain) | xn--ls8h.la |
What the xn-- prefix means
The "xn--" that is always added to the start of the converted result is an identifier meaning "this is a string encoded with Punycode". DNS resolvers, TLS certificates, and mail servers can recognize an "ASCII-converted IDN" by seeing this prefix. The prefix itself has no meaning, and it is an identifier chosen for backward compatibility with existing systems that do not support Unicode.
The reality of emoji domains
Technically, it is possible to convert domains containing emoji into Punycode (examples that could once be registered under some TLDs, such as .la and .ws). In practice, however, there are the following problems.
- Major browsers such as Chrome, Firefox, and Safari have settings that switch emoji domains to the Punycode display in the address bar
- Many mail servers reject emoji domains
- They are hard to read in social media link previews and QR codes
- They are extremely difficult to tell someone verbally
They sometimes become a topic of conversation for a while as something to create buzz for a brand, but they are not a practical option as a business's main domain.
Security issues
Homograph attacks
This is a technique that combines characters from different scripts that look the same (the Cyrillic "а" U+0430 and the Latin "a" U+0061) to create attack domains that cannot be told apart from the legitimate domain.
- Legitimate:
apple.com - Fake:
аpple.com(the first "а" is Cyrillic)
When browsers detect a domain that mixes several scripts, or a specific homograph pattern, they automatically switch to the Punycode display to warn the user. Chrome displays in Punycode the domains that its mixed-script detection judges to be "possibly a homograph".
Phishing countermeasures
In corporate security measures, monitoring IDN domains that resemble your own brand is cited as one of the countermeasures. Services are offered that monitor combinations of Unicode characters that look like major brands such as "apple", "google", and "microsoft".
How to handle it in practice
- Getting a domain: A Japanese domain is converted to Punycode and registered in DNS. Keep both the display and the internal implementation in mind
- Sending email: If you use non-ASCII in the domain of the sender / recipient email address, the other party's mail server may reject it
- SSL certificates: Many certificate authorities support IDN, but the certificate lists it in Punycode form
- Web links: Even if you write a Japanese domain in the HTML
href, the browser automatically converts it to Punycode when communicating
Common misconceptions
- ❌ "Punycode is only for Japanese" → ✅ It supports all Unicode characters
- ❌ "Emoji domains can be used normally" → ✅ Major browsers show them in Punycode, so they are not very practical
- ❌ "xn-- is an unrelated prefix" → ✅ It is required as the identifier of a domain converted to Punycode
Related terms
Was this article helpful?