DeepL CLI is a fast and lightweight command-line tool for the DeepL API, written in Crystal.
- Supports document translation
pdf,docx,txt, etc. - Supports glossaries
- Precompiled binaries available
- Download the binary from the Releases
brew install kojix2/brew/deepl-cliexport HTTP_PROXY=https://[IP]:[port]
export HTTPS_PROXY=https://[IP]:[port]You will need an API key for DeepL. Create one here and set it as an environment variable:
export DEEPL_AUTH_KEY=your_api_key_heredeepl [options] <file>deepl [options] <file>Options:
-i, --input TEXT Input text
-f, --from [LANG] Source language [AUTO]
-t, --to [LANG] Target language [EN]
-p, --paste Input text from clipboard
-g, --glossary NAME Glossary name
-F, --formality OPT Formality (default more less)
-C, --context TEXT Context (experimental)
-S, --split-sentences OPT Split sentences
-A, --ansi Do not remove ANSI escape codesNote: ANSI escape sequences are removed by default.
To translate a document, use the doc subcommand:
deepl doc [options] <file>Options for document translation:
-f, --from [LANG] Source language [AUTO]
-t, --to [LANG] Target language [EN]
-g, --glossary NAME Glossary name
-F, --formality OPT Formality (default more less)
-o, --output FILE Output file
-O, --output-format FORMAT Output file formatSupported file formats.
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
For glossary management, use the glossary subcommand:
deepl glossary [options]Options for glossary management:
list List glossaries
create Create a glossary
delete Delete glossaries
edit Edit glossaries
view View glossaries
-l, --list List glossaries
-p, --language-pairs List language pairsUse the rephrase subcommand to rewrite text in different styles or tones.
Usage: deepl rephrase [options] <file>Options for rephrase:
-i, --input TEXT Input text
-s, --writing-style STYLE academic business casual default simple
-t, --tone TONE confident diplomatic enthusiastic friendlyBelow are examples for translating text, translating documents, and working with glossaries.
To translate the text "Hola mundo" from Spanish (ES) to English (EN):
deepl -i "Hola mundo" -t en # Translation: Hello worldOr, using standard input:
echo "Hola mundo" | deepl -t en # Translation: Hello worldStandard input translation is useful for quick references.
git --help | deepl -t fr | lessThe man command can also be translated (by removing ANSI escape sequences):
man git | deepl -t de | lessTo translate multiple lines, press Ctrl+D when you have finished typing. This is particularly useful when copying and pasting from the clipboard.
deepl -f es
# Hola
# mundo
# Ctrl + DTranslate text from the clipboard:
deepl --pasteYou can also pass a text file as an argument:
deepl -t tr foo.txtIt's possible to pass multiple text files:
deepl -t nl foo.txt bar.txtIf you are translating multiple files, you might want to add the filename to the header:
bat --style header *.txt | deepl -t itTo use a glossary for translation:
deepl -g myglossary -f ruTo refer to the original text, you can use tee dev/stderr:
fortune | tee /dev/stderr | deeplYou can directly translate documents:
deepl doc your.pdf -t pt
# The translated document will be saved as your_PT.pdfTo use a glossary for translation:
deepl doc -g myglossary -f plTo translate a PDF document and save it in docx format:
deepl doc input.pdf -O docx -o output.docx
To translate multiple files, use Unix commands such as find, xargs, fd:
find . -name "*.pdf" -exec deepl doc -t ja {} +ls -1 *.docx | xargs -L1 deepl doc -t kofd -e pdf -e docx -x deepl doc -t zhThe DeepL API supports glossaries. See here for the format of the glossary file. The glossary API is v2. It does not yet support v3.
To create a glossary:
deepl glossary create -n mydic -f en -t pt mydict.tsvTo list glossaries:
deepl glossary listTo list only the names of the glossary:
deepl glossary -lTo use a glossary for text translation:
deepl -g mydict -f en deep.txtTo use a glossary for document translation:
deepl doc -g mydict -f en deep.pdfTo display the contents of the glossary:
deepl glossary view mydictTo list the languages in which glossaries can be created:
deepl glossary -pChange writing style:
bin/deepl rephrase -i "Thanks" -s academic
# Expressions of gratitude are extended.Change tone:
bin/deepl rephrase -i "Thanks" -t friendly
# Thank you so much! I really appreciate it.To display a list of available source languages:
deepl -fTo display a list of available target languages:
deepl -tTo output usage information:
deepl -u
# https://api.deepl.com/v2
# character_count: 614842
# character_limit: 1000000000000| Name | Description |
|---|---|
| DEEPL_AUTH_KEY | DeepL API authentication key |
| DEEPL_TARGET_LANG | Default target language |
| DEEPL_USER_AGENT | User-Agent |
| EDITOR | Text editor for editing glossary |
DeepL CLI automatically detects the target language, but if this does not work, the environment variable DEEPL_TARGET_LANG can be set.
- Fork this repository
- Report bugs
- Fix bugs and submit pull requests
- Write, clarify, or fix documentation
- Suggest or add new features
Compilation from source code
git clone https://github.com/kojix2/deepl-cli
cd deepl-cli
shards build --releaseA compiled binary file will be created in the bin directory. Installation is simply copying the generated binary.
sudo cp bin/deepl /usr/local/bin
If you encounter a bug, follow the command with the -d option and run it. You can view the backtrace.
deepl doc -d a.pdfThis project is licensed under the MIT License.
Happy translating!