tools / punycode
punycode/
Convert internationalized domain names to xn-- Punycode and back. One domain or URL per line, so you can paste a whole list.
Domain
Punycode
What is Punycode
Punycode is the encoding defined in RFC 3492 that writes a domain label containing non-ASCII characters using only letters, digits and hyphens; with the xn-- prefix it can be used in DNS. This page converts line by line between internationalized domain names and the xn-- form, and converts only the host name of a URL.
How it works: label by label, ASCII characters first
- First the writing is unified: NFKC normalization, everything in lowercase, and the Chinese full stop 。 and full-width periods treated as dots.
- The domain is split into labels at the dots; only labels with non-ASCII characters are converted, and plain ASCII labels stay as they are.
- Within a label, the ASCII characters are written out first, followed by a hyphen; the non-ASCII characters are then encoded in order of code point as variable-length integers made of a-z and 0-9. This algorithm is called Bootstring, with base 36.
- Finally, xn-- is put in front of the label. When converting back, only labels starting with xn-- are decoded, and re-encoding the result must give exactly the original, otherwise the page reports that it is not valid Punycode.
Example
The two Chinese characters have no ASCII part, so the encoding follows xn-- directly, and .com stays as it is:
- Input
- 中文.com
- Output
- xn--fiq228c.com
Only the host name of a URL is converted; the ASCII letters mnchen of münchen come first, and the code for ü follows the hyphen:
- Input
- https://münchen.de/path
- Output
- https://xn--mnchen-3ya.de/path
Sources
FAQ
What does "Domains cannot contain …" mean?
It means the line is neither a plain domain nor a complete URL. The ASCII part of a domain may contain only letters, digits and hyphens (the underscore common in DNS records is also allowed); characters such as spaces, / or ! cause this error, and the message names the character. A URL needs its protocol, such as https://, or the path after it is taken as part of the domain. Put one domain or URL per line.
Which form should I use for DNS records, Nginx or an SSL certificate?
Most control panels and config files expect the xn-- form: DNS records, Nginx server_name and the domains in a certificate request all do. A few panels accept the original characters and convert them for you. When in doubt, use the xn-- form.
Can I paste a full URL?
Yes, one per line. Only the host name is converted; the scheme, user name, port, path and query stay as they are. Non-ASCII text in the path or query is not converted, because that part uses percent-encoding; use the URL encoder on this site for it.
Why is everything lowercase, and where did the full-width characters go?
Domain names are case-insensitive, so everything is lowercased first. Full-width letters and digits are converted to their normal forms, and the ideographic full stop 。 and the full-width period count as dots. That way 中文。COM and 中文.com give the same result.
What does "over the 63-character limit per label" mean?
DNS allows at most 63 characters per label (the part between two dots) and 253 for the whole domain, counted on the converted xn-- form. The more varied non-ASCII characters a label has, the longer it gets, and a domain over these limits cannot be registered or resolved.
What if decoding says "not valid Punycode"?
The part after xn-- does not follow the encoding rules, usually because a few characters were lost when copying or a space or quote slipped in. Only labels starting with xn-- are decoded and the rest is output as is, so you can paste whole lines; lines with errors are listed by number below.
My result differs from another tool. Which one is right?
Go by what browsers do. For common Chinese, Japanese, Russian, Greek and German domains, this tool gives the same result as the browser address bar. For example, the German ß is kept and encoded as xn--zca, while some tools that follow older rules turn it into ss and produce a different domain.
Are the domains I enter sent to a server?
No. Everything is converted in your browser; nothing you type is sent to a server, and the page does not look up whether the domain is registered.