HTTP

JSON DeepL's HTTP API for translating JSON objects and text — available when self-hosting.

JSON DeepL exposes the same HTTP endpoints its own web tool uses internally to talk to DeepL. On jsondeepl.com they're restricted to trusted callers — same-origin requests made from the jsondeepl.com frontend itself, not from other websites or scripts — to keep hosting costs predictable for a free, unauthenticated tool.

If you self-host your own copy of the project, that same origin restriction applies relative to your domain instead — so these endpoints become a real API for your own frontend to use, no configuration required. To call them directly (from a script, a build pipeline, another service — anything that isn't a browser page load from your own site), set a NUXT_APP_API_KEY env var on your deployment and send it back as the x-app-api-key header on each request.

curl https://your-domain.example/api/translate-text \
  -H "x-app-api-key: $NUXT_APP_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "token": "your-deepl-key", "src_locale": "en", "to_locale": ["de"], "formality": "prefer_less", "text": "Hello world" }'

Nothing else changes either way: you still bring your own DeepL API key per request, and nothing is stored on the server.

Translate a JSON object

Endpoint: POST /api/translate

Body Parameters

token
string required
Your DeepL API key.
src_locale
string required
The source language code. Refer to the supported languages for available codes. E.g. en *case insensitive
to_locale
string[] required
The target language codes to translate into. Refer to the supported languages for available codes. E.g. ["de", "fr", "es"] *case insensitive
json_files
JsonFile[] required
One or more JSON files to translate.
type JsonFile = {
  dir_name: string // subdirectory to nest this file's output under, or '' for none
  prefix_name: string // filename prefix, e.g. 'app' -> app.de.json, or '' for none
  json: string // the JSON content to translate, as a string
}
The parsed JSON can be nested and contain multiple key-value pairs. Arrays are not supported.
formality
'prefer_less' | 'prefer_more' required
Specifies the formality level of the translation.
  • prefer_less: Translations will be casual tone where applicable.
  • prefer_more: Translations will be more formal where applicable.

Response

files
TranslatedFile[]
One entry per json_files × to_locale combination.
type TranslatedFile = {
  dir_name: string
  filename: string // e.g. 'app.de.json'
  content: string // the translated JSON, stringified
}

Errors

On failure, the response is a standard HTTP error with a JSON body containing statusCode and statusMessage.

StatusMeaning
400One of the json_files entries isn't valid JSON, or the request body failed validation.
401The DeepL API key is invalid.
402The DeepL account has run out of translation quota.
403The request wasn't recognized as a trusted caller — see the note above.
502DeepL couldn't be reached, or translation failed for another reason.

Translate plain text

Endpoint: POST /api/translate-text

Body Parameters

token
string required
Your DeepL API key.
src_locale
string required
The source language code. Refer to the supported languages for available codes.
to_locale
string[] required
The target language codes to translate into.
text
string required
The text to translate.
formality
'prefer_less' | 'prefer_more' required
Specifies the formality level of the translation, same as above.

Response

translations
Record<string, string>
Keyed by target language code.
// e.g. { "de": "Hallo Welt", "fr": "Bonjour le monde" }

Errors

Same shape and status codes as /api/translate above.