Skip to main content

domainToASCII

function domainToASCII
Jump to headingdomainToASCII(domain: string): string

Returns the Punycode ASCII serialization of the domain. If domain is an invalid domain, the empty string is returned.

It performs the inverse operation to domainToUnicode.

import url from 'node:url';

console.log(url.domainToASCII('español.com'));
// Prints xn--espaol-zwa.com
console.log(url.domainToASCII('中文.com'));
// Prints xn--fiq228c.com
console.log(url.domainToASCII('xn--iñvalid.com'));
// Prints an empty string

Parameters Jump to heading

Jump to headingdomain: string

Return Type Jump to heading

string
Back to top