translator-tool / README.md
JSON Translator Tool
Last updated: 4/16/2026GitHub
JSON Translator Tool
A Node.js tool to translate JSON localization files using OpenAI GPT models.
Ideal for multi-language projects (e.g., translating en.json into fr.json, ar.json, etc.).
Features
- Translate JSON files to multiple languages at once
- Supports nested JSON structures
- Outputs translated files in the same folder as the source file
- Automatically adds language suffix to output files (e.g.,
about-ar.json) - Uses
.envfile for storing your OpenAI API key
Prerequisites
- Node.js v18+
- NPM (comes with Node.js)
- OpenAI API Key
Installation & Setup
- Clone the repository
git clone <your-repo-url>
cd json-translator
- Install dependencies
npm install
- Create a .env file in the project root with your OpenAI API key
OPENAI_API_KEY=your_openai_api_key_here
- Make sure your JSON files are ready
Example:
wwwroot/localization/en.json
messages/en/pages/about.json
> ⚠️ Note: Your source JSON files must be in English (e.g., `en.json`) because this tool translates from English to other languages.
- Translate a Single JSON File
node translate-json.js --input "path-to-json-file" --languages ar
- Translate Multiple JSON Files in a Folder
node translate-json.js --inputDir "path-to-json-folder" --languages ar,fr
- Translate Multiple Languages at Once
node translate-json.js --input "path-to-json-file" --languages fr,es,ar