Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4791 pages

Free tool · Developer tools

Punycode converter

This Punycode converter turns a name with accents or other scripts into the plain letters and digits that DNS stores, and back again. smörgåsbord.example becomes xn--smrgsbord-82a8p.example, one name per line, with a part by part table.

  • Free
  • No sign-up
  • Runs in your browser

By Maaz Zindani · Updated

Direction
What you are converting

Each part between dots is converted alone, and xn-- is added to parts that need it. Type one name per line.

Punycode result

xn--smrgsbord-82a8p.example1 of 2 parts converted

xn--smrgsbord-82a8p.example
Lines
1
Parts converted
1
Result length
27 characters
Part by part
InputResultWhat happened
smörgåsbordxn--smrgsbord-82a8pEncoded
exampleexampleUnchanged

How to use the Punycode Converter

  1. Pick Text to Punycode or Punycode to text.
  2. Choose Domain names to convert each part between dots, or Plain string to convert the whole text as one string.
  3. Type or paste one name per line in the box. The result updates while you type.
  4. Press Copy, or Use result as input to run the answer back the other way and check the round trip.

How do you convert a domain name to Punycode?

Punycode is the encoding defined in RFC 3492. It writes any Unicode string with only the letters a to z, the digits 0 to 9 and the hyphen. A domain is converted label by label, where a label is one part between dots. A label with a non-ASCII character is encoded, given the prefix xn--, and joined back with the dots. A label that is plain ASCII is left alone. For smörgåsbord.example the first label becomes xn--smrgsbord-82a8p, and example stays example, which gives xn--smrgsbord-82a8p.example.

The encoded part is smrgsbord-82a8p. Every basic character comes first and keeps its order: the nine letters s, m, r, g, s, b, o, r and d. A hyphen separates them from the rest, and the characters outside ASCII are described after it as numbers. å comes first as 82a and ö follows as 8p. The code points are handled in increasing order, which is why å is written before ö even though ö appears earlier in the word.

Several lines can be pasted at once. BÜCHER.de and plain.example give xn--bcher-kva.de and plain.example. Upper case letters are lowered, since DNS names do not depend on case, and accented letters written as a base letter plus a separate accent are first combined into one character, so both spellings give the same result.

Strings from RFC 3492 and short examples, converted by this tool
LanguageTextPunycodeAs a domain label
Arabic (Egyptian), RFC 3492 sample Aليهمابتكلموشعربي؟egbpdaj6bu4bxfgehfvwxnxn--egbpdaj6bu4bxfgehfvwxn
Chinese (simplified), sample B他们为什么不说中文ihqwcrb4cv8a8dqg056pqjyexn--ihqwcrb4cv8a8dqg056pqjye
Czech, sample DPročprostěnemluvíčeskyProprostnemluvesky-uyb24dma41axn--Proprostnemluvesky-uyb24dma41a
Germanbücherbcher-kvaxn--bcher-kva
Spanishmañanamaana-ptaxn--maana-pta
Japanese日本語wgv71a119exn--wgv71a119e
Russianпримерe1afmkfdxn--e1afmkfd

What does the xn-- prefix mean, and how do you read Punycode back?

RFC 3492 defines only the encoding of a string. The prefix xn-- is what marks a DNS label as encoded, so software knows to decode it. RFC 6068 shows it in practice: the Japanese word for natto, 納豆, is written as xn--99zt52a in a mail address, and the tool gives xn--99zt52a.example.org for 納豆.example.org.

To decode, the tool removes xn--, reads everything before the last hyphen as basic characters and treats the rest as base 36 numbers, where a to z mean 0 to 25 and 0 to 9 mean 26 to 35. Each number says where to insert the next character. A label without the prefix is kept as typed. Digits in the encoded text may be upper or lower case.

Bad input is reported with the label that failed, for example a character that is not a Punycode digit, a number that ends too early, or a number too large to be a character. Nothing is guessed.

When should you use plain string mode?

Plain string mode applies RFC 3492 to the whole text with no prefix and no dots handling. It is what you want when a protocol or a library gives you the raw encoded string. The all ASCII text abc becomes abc-, because the encoder always appends the hyphen when basic characters exist, and that text decodes back to abc. A hyphen inside the input is allowed: bücher-shop gives bcher-shop-9db, and the decoder splits at the last hyphen.

Three identical letters show how compact the numbers are. üüü gives tdaaa: with no basic characters there is no hyphen, and each repeat costs a single digit.

What are the limits of this converter?

A DNS label may hold at most 63 octets, a limit set in RFC 1035. The encoded form with its xn-- prefix counts, so a long label in a script that needs several digits per character can pass it. The tool stops with a message that names the label and its length.

The page also converts at most 2,000 characters of text at a time when encoding and 8,000 when decoding, since the Punycode form is longer. Punycode needs a pass over the text for every distinct character, so very long input would slow the tab, and a message asks you to split it.

Domain mode applies Unicode normalization form C and lower casing, and nothing more. It does not apply the full mapping tables that a browser uses, and it does not check which characters a registry allows. Two names that look alike can use different scripts, so read a decoded name carefully before trusting it.

Use it with

Questions

What is Punycode?

Punycode is the encoding from RFC 3492 that writes a Unicode string with only ASCII letters, digits and hyphens. It is used for internationalized domain names.

How do I convert a Unicode domain to xn-- form?

Type it in domain mode with Text to Punycode selected. smörgåsbord.example gives xn--smrgsbord-82a8p.example. Each label with a non-ASCII character gets the xn-- prefix and the others stay as they are.

How do I decode an xn-- domain?

Choose Punycode to text and paste the name, for example xn--99zt52a.example.org, which reads 納豆.example.org. Labels without xn-- are left as they are.

Why is the hyphen in the middle of the result?

The basic characters of the input come first, then a hyphen, then the rest as numbers. In smrgsbord-82a8p the part before the hyphen is the plain letters of smörgåsbord.

What is the longest name I can convert?

A single label can be at most 63 characters after encoding, including xn--. The tool reports the label that is too long.

Is the text I type sent anywhere?

No. The encoding is plain arithmetic done in this page, so the names you enter are not uploaded.

The tool's results are computed in your browser by the code on this page, using the sources listed above; the explanations are checked against the tool's own output.