Dev tools

Punycode encode

Punycode encode. Runs on your device, nothing is uploaded.

Runs on your device. The file is never uploaded.

Punycode encode applies the RFC 3492 bootstring algorithm to your text, copying the ASCII characters out first, then a hyphen, then digits saying where the rest belong. This is the transform behind xn-- labels in a domain name. The tool adds no xn-- prefix, splits on no dots and applies no IDNA normalisation.

Input

Questions

What is Punycode for?

Internationalised domain names. It is the RFC 3492 bootstring algorithm that turns a label containing non-ASCII characters into pure ASCII so it can travel through the DNS, which is where the xn-- labels you see in browser address bars come from.

Does it add the xn-- prefix?

No. The tool emits the raw bootstring output. The ACE prefix that marks a label as Punycode in DNS is not attached, so put xn-- in front yourself if you are building a real domain label. Nothing here checks label length or the other IDNA rules either.

Can I run a whole domain through it?

Not usefully. The encoder treats your entire input as one label and does not split on dots, so a full domain name comes back as a single mangled string. Encode one label at a time, the part between two dots, and rejoin them yourself.

Why is there a hyphen in the middle of the output?

That is the delimiter. All the ASCII characters of the input are copied out first, then a hyphen, then the encoded instructions for inserting the non-ASCII ones. If your input has no ASCII characters at all, there is no hyphen and the output is encoded digits only.

Why does plain ASCII input come back with a trailing hyphen?

Because the delimiter is written after the basic characters whether or not anything follows it. An input of abc gives abc- since there are no non-ASCII characters left to encode. A real IDNA encoder would leave a pure ASCII label alone; here you can drop the trailing hyphen.

Does it apply case folding or normalisation first?

No. There is no nameprep or IDNA mapping step, so uppercase stays uppercase and characters that should normalise to the same form are encoded differently. Normalise your text before encoding if you need the result to match what a browser produces.

Related Dev tools