URL

url.domainToASCII()

Converts an internationalized domain to ASCII for protocol use. An empty result indicates invalid input; conversion is not an anti-spoofing check. Tested on Node.js 22.16.0. Example output (one line per entry): ["xn--bcher-kva.example"].

Formal Syntax & Structure

nodejs syntaxnodejs
domainToASCII(domain)

Parameters & Attributes

NameTypeDescription
domainstringDomain name.

Return Value

string

ASCII domain or empty string.

Working Example

Example Snippetnodejs
import { domainToASCII } from 'node:url';console.log(domainToASCII('bücher.example'));
Node.js Reference