Punycode Converter: Encoder and Decoder

How to use Punycode encoder tool?

A few simple steps:

  1. Type or paste your URL or hostname that needs to be encoded/converted to punycode syntax to the first input.

  2. Click on the big "Encode with Punycode" button.

  3. The result will appear in the second input.

  4. If you need to decode Punycode syntax i.e. convert it back to text with Unicode characters, please use the second input and click on "Decode Punycode syntax" button.

  5. You can click on "Paste example" button at the top of the page to quicky see the tool in action.

Punycode encoding syntax: What it is and Why it is needed

Punycode is a special encoding algorithm that basically replaces Unicode (UTF-8) characters or letters in a text with a limited set ASCII characters. The converted string will contain only a subset of ASCII characters: only English alphabet letters (A-Z), digits, and hyphens. This set of characters is called the letter–digit–hyphen (LDH). Punycode conversion enables the use of Unicode characters in hostnames of URLs. The common use case is to encode internationalized domain names (IDN). The encoded hostname will be compatible with the restrictions imposed by the Domain Name System (DNS). Domain names have strict rules: only A-Z letters, numbers, and symbols (only minus sign (-) and period (.)). Punycode syntax allows using letters from non-Latin languages such as Chinese, Thai, Cyrillic, Japanese, and Indian (Hindi) in domain names.

How to encode URL or hostname with Punycode using JavaScript?

There is a dedicated open source npm package for that - punycode.js. It will help to encode your URL with Punycode syntax and vice-versa.