Skip to main content

Punycode Encoder (IDN to ASCII) Convert internationalized domain names to Punycode (xn--) format.

Punycode Encode illustration
🔐

Punycode Encode

Convert internationalized domain names to Punycode (xn--) format.

1

Enter Domain

Type or paste the internationalized domain name.

2

View Punycode

The Punycode-encoded domain appears instantly.

3

Copy Punycode

Click Copy to copy the encoded domain.

Loading tool...

What Is Punycode Encode?

Punycode Encode is an encoding scheme that represents internationalized domain names (IDN) using only ASCII characters by converting Unicode domain labels to ASCII-compatible encoding (ACE) prefixed with xn--. It's primarily used by developers and system administrators who work with domain name systems, particularly those dealing with non-English languages or special characters in URLs. One specific problem it solves is enabling the use of internationalized domain names on DNS servers that only support ASCII, thereby allowing users to access websites with domain names containing Unicode characters.

This tool uses a delta encoding algorithm to process code points and represents integers using a generalized variable-length format, as specified in RFC 3492. What makes this implementation distinct is its ability to handle each label of the domain name separately, checking for Unicode characters and applying punycode encode conversion only when necessary, while leaving ASCII labels unchanged.

The tool's client-side processing ensures that all encoding operations are performed locally without transmitting sensitive data over the network, making it a suitable choice as an idn to punycode converter or punycode converter. It produces output in the xn-- encoding format, which can be used directly with DNS servers, effectively serving as a reliable internationalized domain name solution for developers working with diverse character sets and languages.

Why Use Punycode Encode?

  • Convert international domains to DNS-compatible ASCII format
  • RFC 3492 compliant Punycode encoding
  • 100% client-side — data never leaves your browser
  • Free online tool for domain name testing

Common Use Cases

Domain Registration

Check Punycode form of international domains before registration.

DNS Configuration

Get ASCII form of IDN domains for DNS records.

Email Configuration

Configure email servers with Punycode domain forms.

Security Analysis

Detect Punycode-based homograph attacks.

Technical Guide

The tool works by first separating ASCII and non-ASCII characters in the input string, using Unicode code points to identify the character set. It then uses a delta encoding algorithm, as specified in RFC 3492, to process the non-ASCII code points, representing integers in a generalized variable-length format. The `punycodeEncode` function takes an input string and applies this algorithm, utilizing the `charCodeAt` method to get the Unicode code point for each character.

The adaptive bias calculation is performed using the `adapt` function, which adjusts the bias based on the delta value, number of points, and whether it's the first time through the loop. The `encodeDigit` function maps integers to ASCII characters, adding 22 to the input digit and applying an additional offset if the digit is less than 26. The encoded digits are then appended to the output array, which stores the Punycode-encoded result.

In terms of data structures, the tool uses arrays to store the basic ASCII characters, code points, and output digits. It also utilizes JavaScript's built-in `String` methods, such as `fromCodePoint`, to convert Unicode code points back into a string. The React library is used for building the user interface, with the `useCallback` hook memoizing the `onProcess` function to prevent unnecessary re-renders. When processing domain names, the tool splits the input string at dots using the `split` method and applies Punycode encoding to each label independently, checking for Unicode characters using a regular expression (`/[^\x00-\x7F]/`).

The encoded labels are then joined back together with dots in between using the `join` method. The resulting Punycode-encoded string is prefixed with 'xn--' to identify it as a valid Punycode label. This implementation ensures that each domain label is handled correctly, whether it contains ASCII or non-ASCII characters, producing output that can be used directly with DNS servers.

Tips & Best Practices

  • 1
    The xn-- prefix identifies a Punycode-encoded domain label
  • 2
    Each label between dots is encoded separately
  • 3
    Use to detect homograph attacks
  • 4
    Only needed for domain names — URLs use percent-encoding for paths

Related Tools

Frequently Asked Questions

Q Is this tool free?
Yes, completely free with no signup required.
Q Is my data secure?
Yes. All processing is 100% client-side.
Q What is the xn-- prefix?
xn-- is the ACE prefix that identifies a Punycode-encoded domain label.
Q What browsers are supported?
All modern browsers including Chrome, Firefox, Safari, and Edge.
Q Can I encode full URLs?
This tool encodes domain names. For URL paths, use the URL Encoder.

About This Tool

Punycode Encode is a free online tool by FreeToolkit.ai. All processing happens directly in your browser — your data never leaves your device. No registration or installation required.