To get started with JSON DeepL CLI, you need to initialize it in your project. This will create a configuration file that stores your settings and preferences.
npx jsondeepl@latest
Or if you have installed JSON DeepL CLI globally or as a dependency, you can run below command at the root of your project:
jsondeepl
First time running the command on your project will create a jsondeepl directory in your project root along with a config.json file. This file contains the default configuration settings for JSON DeepL CLI.
jsondeepl/config.json file to set your source language, target languages, and other options as needed.The configuration file is a JSON file that contains the settings for JSON DeepL CLI. You can modify this file to customize the behavior of the CLI. See config options for more details.
{
"source": "en", // add your source (default) language here
"target": ["de", "zh"], // add your target languages here
"langDir": "./i18n/locales", // change this to your locales directory
"options": {
"autoMerge": true,
"prompt": true
}
}
JSONDEEPL_API_KEY="your_deepl_api_key_here"
Once you have modified the configuration file, you can run the CLI command again to translate your JSON files.
npx jsondeepl@latest
jsondeepl
langDir directory with the translated files. It is recommended to use a version control system like Git to keep track of your changes and avoid surprises.You can rerun the CLI command whenever you make changes to your source JSON file. The CLI will detect the changes and update the translations accordingly. it will do the following:
this way, your translations will always be synced with your source JSON file without losing any existing translations.
The CLI automatically detects when you add new target languages to your configuration and handles them intelligently:
.json file in your langDirInitial Setup:
// jsondeepl/config.json
{
"source": "en",
"target": ["fr", "es"],
"langDir": "./i18n/locales"
}
Files:
i18n/locales/
├── en.json (100 keys)
├── fr.json (100 keys - fully translated)
└── es.json (100 keys - fully translated)
jsondeepl/
└── en-lock.json (100 keys)
Update config:
{
"source": "en",
"target": ["fr", "es", "de"], // Added "de"
"langDir": "./i18n/locales"
}
Run the CLI:
jsondeepl
What Happens:
de.json doesn't existDetected new target language: de - will translate all keysen.json (incremental)en.json (incremental)en.json (full translation)fr: 0 characters (no changes in source)
es: 0 characters (no changes in source)
de: 5000 characters (full translation of all keys)
Total characters to translate: 5000
✅ No manual intervention needed - Just add the language code to config
✅ Cost efficient - Only pays for what needs to be translated
✅ Smart detection - Handles mixed scenarios automatically
✅ Works with existing workflow - No breaking changes
// Before: ["en-US", "fr"]
// After: ["en-US", "fr", "de"]
Result: German gets full translation, French gets incremental updates
// Before: ["en", "fr"]
// After: ["en", "fr", "de", "es", "it"]
Result: German, Spanish, Italian get full translations, French gets incremental updates