Translate documents
The document translation API allows you to translate whole documents and supports the following file types and extensions:
docx
/doc
- Microsoft Word Documentpptx
- Microsoft PowerPoint Documentxlsx
- Microsoft Excel Documentpdf
- Portable Document Formathtm / html
- HTML Documenttxt
- Plain Text Documentxlf / xliff
- XLIFF Document, version 2.1srt
- SRT (SubRip Subtitle) Document
Please note that with every submitted document of type .pptx, .docx, .doc, .xlsx, or .pdf, you are billed a minimum of 50,000 characters with the DeepL API plan, no matter how many characters are included in the document.
The maximum upload limit for documents is available here and may vary based on API plan and document type.
We also provide a spec that is auto-generated from DeepL's OpenAPI file. You can find it here.
When translating a doc
file, you will receive a docx
file as the output format.
Step 1: upload a document to the /document
endpoint
/document
endpointThis call uploads a document and queues it for translation. The call returns once the upload is complete, returning a document ID and key which can be used to query the translation status and to download the translated document once translation is complete.
Because the request includes a file upload, it must be an HTTP POST request with content type multipart/form-data
.
Please be aware that the uploaded document is automatically removed from the server once the translated document has been downloaded. You have to upload the document again in order to restart the translation.
You may specify the glossary to use for the document translation using the glossary_id
parameter. Important: This requires the source_lang
parameter to be set and the language pair of the glossary has to match the language pair of the request.
For more detail about request body parameters, see the Request Body Descriptions section further down on the page.
The examples below use our API Pro endpoint https://api.deepl.com. If you're an API Free user, remember to update your requests to use https://api-free.deepl.com instead.
These examples are for demonstration purposes only. In production code, the authentication key should not be hard-coded but instead fetched from a configuration file or environment variable.
Request Body Descriptions
Note: the model_type
parameter is not supported for API document translation and is only supported for text translation. It’s possible to submit a document translation request that includes the parameter, but the parameter will be ignored and will not have an effect on translation results.
source_lang
(optional)
Language of the text to be translated. If omitted, the API will attempt to detect the language of the text and translate it. You can find supported languages here.
Type: string
target_lang
(required)
The language into which the text should be translated. You can find supported languages here.
Type: string
file
(required)
The document file to be translated. The file name should be included in this part's content disposition. As an alternative, the filename parameter can be used. The following file types and extensions are supported:
docx
- Microsoft Word Documentpptx
- Microsoft PowerPoint Documentxlsx
- Microsoft Excel Documentpdf
- Portable Document Formathtm / html
- HTML Documenttxt
- Plain Text Documentxlf / xliff
- XLIFF Document, version 2.1
Type: binary
filename
(optional)
The name of the uploaded file. Can be used as an alternative to including the file name in the file part's content disposition.
Type: string
formality
(optional)
Sets whether the translated text should lean towards formal or informal language. This feature currently only works for target languages DE
(German), FR
(French), IT
(Italian), ES
(Spanish), NL
(Dutch), PL
(Polish), PT-BR
and PT-PT
(Portuguese), JA
(Japanese), and RU
(Russian). Learn more about the plain/polite feature for Japanese here. Setting this parameter with a target language that does not support formality will fail, unless one of the prefer_...
options are used. Possible options are:
default
(default)more
- for a more formal languageless
- for a more informal languageprefer_more
- for a more formal language if available, otherwise fallback to default formalityprefer_less
- for a more informal language if available, otherwise fallback to default formality
Type: string
glossary_id
(optional)
A unique ID assigned to a glossary.
Type: string
output_format
(optional)
File extension of desired format of translated file, for example: pdf
. If unspecified, by default the translated file will be in the same format as the input file.
Note: Not all combinations of input file and translation file extensions are permitted. See Document format conversions for the permitted combinations.
Type: string
Step 2: check the document status and wait for translation to complete
Retrieve the current status of a document translation process.
Please note that the seconds_remaining
parameter is just an estimate and can be unreliable (e.g. sometimes it might return 2^27). We recommend polling the document status, either in regular intervals or with exponential back-off. Translation time depends on the document size and server load, but should be in the order of seconds for small documents and 1-2 minutes for larger documents once translation has started.
The example below uses our API Pro endpoint https://api.deepl.com. If you're an API Free user, remember to update your requests to use https://api-free.deepl.com instead.
Step 3: download the translated document
Once the status of the document translation process is done
, the result can be downloaded.
For privacy reasons the translated document is automatically removed from the server once it was downloaded and cannot be downloaded again.
The example below uses our API Pro endpoint https://api.deepl.com. If you're an API Free user, remember to update your requests to use https://api-free.deepl.com instead.
Client libraries and document translation
The examples on this page show how to translate documents with DeepL using the API directly.
DeepL's client libraries simplify API document translation by providing a convenience function to upload the document, check translation status and download the translated document with a single function call.
Document format conversions
By default, the DeepL API returns translated documents in the same format as the input document.
Using the output_format
parameter during document upload, you can select alternative output formats. For example, you can translate a PDF file and receive the translation as an editable Microsoft Word Document (DOCX), allowing you to make additional changes as necessary.
The range of alternative output formats you can select are indicated in the table below:
docx
- Microsoft Word Document
Others
None
Last updated