Punycode

Internationalized domain name encoding
~/tools/punycode $ ./convert
Operation mode:
input.txt
output.txt
🌐

Punycode (internationalized domain encoding)

**Use cases**: Handle internationalized domain names (IDN) with non-ASCII characters, such as Chinese or Japanese domains. Browsers convert Unicode domains to Punycode (starting with `xn--`) before DNS lookup. Useful when building redirects with non-ASCII hosts or displaying decoded domains from URLs.

**How it works**: Punycode encodes Unicode strings into ASCII-only text (letters, digits, and hyphens). Unicode is compressed into an ASCII form and prefixed with `xn--` so DNS can resolve internationalized domains.

Examples:
中国.comxn--fiqs8s.com
日本.jpxn--wgv71a.jp
münchen.dexn--mnchen-3ya.de

Punycode & IDN Converter

DNS stores only ASCII labels, so Unicode domains such as example.测试 appear as ACE (Punycode like xn--…) behind the scenes. Convert between display labels and Punycode to debug TLS SAN entries, browser chrome, and deep links without mis-splitting labels or double-encoding hostnames.

How to use

  1. Paste a Unicode hostname or single label, or paste an ACE string that already starts with `xn--`.
  2. Convert to the opposite form and confirm each dot-separated label is handled independently for multi-label internationalized names.
  3. Use the output when configuring certificates, allowlists, email deliverability, and log parsers—then verify against your resolver, CDN, and app entitlements on a real device.

FAQ

Why does my Chinese domain show as xn-- in server tooling?
DNS always records IDNs as Punycode per RFC 3492; user agents decode for humans. Seeing ACE in curl or mail logs is expected—match it to your TLS SANs and the exact hostname your services resolve.
Is Punycode the same as URL percent-encoding?
No. Percent-encoding escapes UTF-8 bytes for URLs; Punycode encodes Unicode into DNS-safe ASCII labels. Applying the wrong transform breaks lookups—use each where its protocol specifies.
Can two different Unicode labels collide after Punycode?
Conforming inputs map bijectively; collisions should not occur. Still audit homoglyphs and phishing separately—encoding correctness does not imply visual uniqueness.