# Punycode Converter

POST /tools/punycode-converter: Converts each non-empty line between unicode and punycode.

Source: https://docs.deepinfo.com/reference/utilities/punycode-converter/

Last updated: 2026-12-05

---
`POST https://api.deepinfo.com/v1/tools/punycode-converter`

Converts each non-empty line between unicode and punycode. `target` picks the direction: `punycode` turns `müşteri.example.com` into `xn--mteri-kva70e.example.com`, `unicode` turns it back. Both directions match the IDNA conversion a standard library does (checked against Python's, 2026-10-08).

For a line starting with `http://` or `https://` only the host name is converted; a name that is already in the target form is returned unchanged.

> A line that cannot be converted does **not** fail the request, although the spec says it does: the response is `200` and that line comes back as an **empty string**, in place, so `results` stays aligned with the input lines. Check for empty entries. (Measured 2026-10-08 with the line `xn--`.)

## Authentication

Send your API key in the `apikey` request header.

## Request Body

| Parameter | Type | Required | Description |
|---|---|---|---|
| `target` | string | Required | Conversion direction: punycode converts unicode to punycode, unicode converts punycode to unicode. One of `punycode`, `unicode` |
| `text` | string | Required | Text holding one domain or URL per line. Limited to 1,000,000 characters and 10,000 lines. |

```json
{
  "text": "müşteri.example.com\nhttps://örnek.example.org/path\nwww.example.com",
  "target": "punycode"
}
```

## Response Fields

| Field | Type | Description |
|---|---|---|
| `results` | array of string | The records on this page, with the `results[].*` fields below. |

## Response Schema

| Field | Type |
|---|---|
| `results` | array<string> |

## Examples

### 200 · OK

```bash
curl -X POST 'https://api.deepinfo.com/v1/tools/punycode-converter' \
  -H 'apikey: YOUR_API_KEY' \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "text": "müşteri.example.com\nhttps://örnek.example.org/path\nwww.example.com",
  "target": "punycode"
}'
```

`Content-Type: application/json` · `deepinfo-request-id: 5f0c6a8e-1b2d-4c3e-9f4a-7b8c9d0e1f2a`

```json
{
  "results": [
    "xn--mteri-kva70e.example.com",
    "https://xn--rnek-4qa.example.org/path"
  ]
}
```

### 200 · target=unicode

```bash
curl -X POST 'https://api.deepinfo.com/v1/tools/punycode-converter' \
  -H 'apikey: YOUR_API_KEY' \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "text": "xn--mteri-h9ac.example.com\nxn--rnek-xpa.example.org",
  "target": "unicode"
}'
```

`Content-Type: application/json` · `deepinfo-request-id: 5f0c6a8e-1b2d-4c3e-9f4a-7b8c9d0e1f2a`

```json
{
  "results": [
    "mtōerōi.example.com",
    "rneík.example.org"
  ]
}
```

### 400 · Invalid Parameter (invalid target)

```bash
curl -X POST 'https://api.deepinfo.com/v1/tools/punycode-converter' \
  -H 'apikey: YOUR_API_KEY' \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "text": "example.com",
  "target": "ascii"
}'
```

`Content-Type: application/json` · `deepinfo-request-id: 5f0c6a8e-1b2d-4c3e-9f4a-7b8c9d0e1f2a`

```json
{
  "code": 10400,
  "parameters": [
    {
      "details": [
        "Target only accept punycode or unicode."
      ],
      "subcode": 19007
    }
  ],
  "solution": "https://docs.deepinfo.com/reference/"
}
```

### 400 · Validation Error (target missing)

```bash
curl -X POST 'https://api.deepinfo.com/v1/tools/punycode-converter' \
  -H 'apikey: YOUR_API_KEY' \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "text": "example.com"
}'
```

`Content-Type: application/json` · `deepinfo-request-id: 5f0c6a8e-1b2d-4c3e-9f4a-7b8c9d0e1f2a`

```json
{
  "code": 10400,
  "parameters": [
    {
      "details": [
        "No target is provided as input."
      ],
      "subcode": 19006
    }
  ],
  "solution": "https://docs.deepinfo.com/reference/"
}
```
