Converters

Punycode Converter

Encode and decode internationalized domain names with Punycode.

Advertisement

What Is Punycode and Why Does It Exist?

The Domain Name System (DNS) was designed in the 1980s to work with a limited subset of ASCII characters: the letters A through Z, digits 0 through 9, and the hyphen. This design predates the global internet by decades and makes no provision for the billions of people whose languages use different scripts — Arabic, Cyrillic, Chinese, Japanese, Devanagari, and hundreds of others.

Punycode is the encoding algorithm that bridges this gap. Defined in RFC 3492, Punycode converts Unicode strings into ASCII-compatible strings that the DNS infrastructure can handle. Internationalized Domain Names (IDNs) use Punycode to represent non-ASCII characters in domain names while remaining compatible with the existing DNS protocol, resolver software, and certificate infrastructure.

A Punycode-encoded domain name begins with the ASCII Compatible Encoding (ACE) prefix `xn--` followed by the encoded string. For example, the domain `münchen.de` (Munich in German) becomes `xn--mnchen-3ya.de` in Punycode. To human users, the domain appears in its native Unicode form in modern browsers. To the DNS system, it is transmitted and resolved as the ASCII Punycode form.

  • DNS originally supported only ASCII characters
  • Punycode encodes Unicode into ASCII-compatible strings
  • IDNs use the xn-- prefix for Punycode representation
  • Browsers display Unicode; DNS uses Punycode behind the scenes
  • Standardized in RFC 3492 as part of the IDNA framework

How Punycode Encoding Works

Punycode is not a simple substitution cipher. It is a sophisticated algorithm that encodes Unicode code points into a sequence of ASCII characters while preserving the ability to decode back to the original Unicode string without ambiguity.

The algorithm separates ASCII characters from non-ASCII characters. All basic ASCII characters from the input are copied directly to the output, followed by a delimiter (a hyphen). Non-ASCII characters are then encoded using a variable-length integer representation based on base-36 digits (0-9 and a-z). The encoding uses a delta algorithm that optimizes for common cases where non-ASCII characters appear near the beginning of the Unicode space.

The variable-length encoding is what makes Punycode compact for many real-world strings. Characters with lower Unicode code points require fewer base-36 digits to represent than characters with higher code points. This means that domains using characters from commonly used scripts — such as Latin-1 accented letters or basic Cyrillic — produce relatively short Punycode strings, while rare characters produce longer ones.

Decoding reverses this process. The decoder separates the literal ASCII prefix from the encoded suffix, reconstructs the Unicode code points from the base-36 deltas, and assembles the final Unicode string. The entire process is deterministic and lossless, producing exactly the original input.

  • Separates ASCII and non-ASCII characters
  • Uses base-36 variable-length integer encoding
  • Delta algorithm optimizes for common Unicode ranges
  • Encoding is deterministic and fully reversible
  • Produces compact output for frequently used scripts

Security Considerations: Homograph Attacks

Internationalized domain names introduce a significant security challenge known as the homograph attack. Because different Unicode scripts contain visually similar characters, attackers can register domains that look identical to legitimate ones but resolve to entirely different servers under the control of the attacker.

The classic example uses Cyrillic characters that look like Latin letters. The Cyrillic letter а (U+0430) looks identical to the Latin letter a (U+0061) in most fonts. An attacker could register `раypal.com` using Cyrillic letters and create a phishing site that is visually indistinguishable from `paypal.com` in the browser address bar. Modern browsers have implemented defenses, but the risk remains real.

Browser vendors address this through a mix of techniques. IDN display rules restrict which scripts can appear together in a single domain. Mixed-script domains — those containing characters from multiple scripts — are displayed as Punycode rather than Unicode to prevent visual spoofing. Some browsers display all IDNs as Punycode in certain contexts, such as when the domain does not match the user preferred language.

Developers and security professionals should understand these limitations. When validating domain names in applications, always compare the Punycode forms rather than the Unicode forms. When displaying domain names to users in security-critical contexts, consider showing the Punycode form as a tooltip or secondary display so users can verify the true domain.

  • Visually similar characters from different scripts enable spoofing
  • Cyrillic and Latin homographs are the most common attack vector
  • Browsers restrict mixed-script IDN display
  • Always compare Punycode forms for security validation
  • Display Punycode in security-critical contexts

How Our Punycode Converter Works

Our Punycode Converter is a client-side tool that implements the full RFC 3492 encoding and decoding algorithm in JavaScript. It handles any valid Unicode input and produces correct Punycode output for all Unicode code points up to the maximum defined range.

To encode a domain name, enter the Unicode form in the input field — for example, `测试.com` or `café.fr`. The converter validates that the input contains valid Unicode characters and then applies the Punycode algorithm to produce the ASCII-compatible form: `xn--0zwm56d.com` and `xn--caf-dma.fr` respectively. The output updates in real time as you type.

To decode a Punycode domain, enter the ASCII form beginning with `xn--`. The converter strips the prefix, applies the decoding algorithm, and displays the Unicode representation. This is useful when examining domains in server logs, certificate transparency logs, or DNS queries where only the Punycode form is visible.

The tool also validates IDNA2008 compatibility where applicable, flagging characters that are disallowed in domain names according to the latest ICANN standards. This helps you identify domains that may be rejected by registrars or resolvers even if they are technically encodable.

  • Full RFC 3492 implementation in the browser
  • Real-time encoding from Unicode to Punycode
  • Real-time decoding from Punycode to Unicode
  • IDNA2008 validation for domain name compliance
  • No data sent to servers — all processing is client-side

Practical Applications of Punycode Conversion

Punycode conversion is not merely an academic exercise. It has direct practical applications in web development, system administration, security analysis, and international business operations.

Web developers working with international users need to handle IDN inputs in forms, URLs, and search fields. When a user types a non-ASCII domain into your application, you may need to convert it to Punycode before making DNS queries, validating SSL certificates, or storing it in a database that expects ASCII. Our converter lets you test these conversions during development.

System administrators reviewing DNS logs and packet captures see only Punycode representations. Decoding these to Unicode helps identify which actual domains are being queried on your network. This is essential for threat hunting, content filtering, and compliance monitoring in multilingual environments.

Security researchers analyzing phishing campaigns and domain squatting use Punycode conversion to uncover homograph attacks. A suspicious domain that appears legitimate in Unicode may reveal its true nature when converted to and from Punycode, exposing the mixed scripts or deceptive character substitutions used by attackers.

Domain investors and trademark professionals use Punycode to research internationalized versions of brand names. Understanding how a brand name converts to Punycode helps identify potentially infringing registrations and plan defensive domain registration strategies across different language markets.

  • Handle IDN inputs in web applications
  • Decode DNS logs and network traffic
  • Analyze potential homograph phishing domains
  • Research internationalized brand name registrations
  • Validate domain names before registration or deployment