Skip to content
uencoder

Punycode

Punycode is an encoding that converts Unicode strings (internationalized domain names) into ASCII-compatible strings, with output marked by the xn-- prefix.

Purpose

It lets domain names in non-Latin scripts resolve over the ASCII-only DNS infrastructure while staying compatible with existing systems.

Mechanism

All basic ASCII code points in the input are kept in place; non-ASCII code points are appended at the end via generalized variable-length integer encoding, with a delimiter and insertion positions recovering the order. The output consists entirely of lowercase ASCII letters, digits, and hyphens.

Use cases

  • Internationalized domain names (e.g., a Japanese example domain whose labels encode to xn--r8jz45g.xn--zckzah)
  • IDN registration and resolution
  • Internationalized email addresses (SMTPUTF8 fallback)
  • Compatibility layer for DNS software

Examples

  • Input
    münchen
    Output
    xn--mnchen-3ya

    Encoding a German city name

Common errors

Skipping homograph attack checks for IDN names
Use ICU to detect suspicious mixed scripts before rendering

Related terms

Related tools

References