Skip to main content
domainToASCII - node__url.d.ts - Node documentation
function domainToASCII

Usage in Deno

```typescript import { domainToASCII } from "node:node__url.d.ts"; ```
domainToASCII(domain: string): string
Returns the [Punycode](https://tools.ietf.org/html/rfc5891#section-4.4) ASCII serialization of the `domain`. If `domain` is an invalid domain, the empty string is returned. It performs the inverse operation to [domainToUnicode](../.././node__url.d.ts/~/domainToUnicode). ```js 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

domain: string

Return Type

string