Node.js Tutorial- punnycode

The tutorial provides the details on the node.js punnycode module. The node.js punnycode module provides the character encoding scheme as per the guidelines defined by RFC 3492 . The puunycode module converts the unicode string (UTF8) to ASCII string of characters for use in Internationalized Domain Names (IDN). The need of conversion is required as most browsers support ASCII string of chanracters whereas IDN names are non-ASCII and thus required conversion.

The Internationalized Domain Name, ‘例.com’ (equivalent to ‘’) is represented by Punycode as the ASCII string ‘’. The node.js string decoder module can be accessed using the command

const punycode = require('punycode');

Node.js puunycode methods in node.js

The below given are the available methods in punnycode API

punnycode method namepunnycode method description
punycode.decode(string)converts string of ASCII symbols to string of Unicode symbol
punycode.encode(string) converts string of Unicode symbol to string of ASCII symbols
punycode.toASCII(domain) convert a Unicode string of the domain name to Punnycode string of ASCII symbols
punycode.toUnicode(domain) convert string of ASCII symbols of the domain name to Unicode String symbols ( non-ASCII)