# Convert an email domain to punycode

Keep the local part and convert an international domain to its ASCII xn-- form.

Canonical: https://1loc.dev/email/convert-an-email-domain-to-punycode/
Version: 1.0.0
Runtime: JavaScript · Node.js 22 / modern browsers
Verification: Local fixtures; no external services
Updated: 2026-10-28

## Implementation

```javascript
function toAsciiAddress(address) { const at = address.lastIndexOf('@'); return `${address.slice(0, at)}@${new URL(`http://${address.slice(at + 1)}`).hostname}`; }
```

## Input

```json
"ana@bücher.example"
```

## Expected output

```json
"ana@xn--bcher-kva.example"
```

## Edge case

Input:
```json
"ana@EXAMPLE.com"
```
Output:
```json
"ana@example.com"
```

## Limits

- Oveyon accepts ASCII addresses only: an international domain must be sent in its xn-- form, anything else is refused with address_not_ascii.
- Only the domain is converted. A non-ASCII local part (EAI) cannot be made ASCII this way.

The lab validates types and size before calling this function. Add equivalent validation at your own trust boundary.

## Source and license

Author: Oveyon, written for this edition; not part of the original 1loc collection.
Copyright (c) 2026 Oveyon
License: MIT — https://1loc.dev/licenses/
Maintainer: Oveyon
