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 .env file for storing your OpenAI API key

Prerequisites

  • Node.js v18+
  • NPM (comes with Node.js)
  • OpenAI API Key

Installation & Setup

  1. Clone the repository
git clone <your-repo-url>
cd json-translator
  1. Install dependencies
npm install
  1. Create a .env file in the project root with your OpenAI API key
OPENAI_API_KEY=your_openai_api_key_here
  1. 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.
  1. Translate a Single JSON File
node translate-json.js --input "path-to-json-file" --languages ar
  1. Translate Multiple JSON Files in a Folder
node translate-json.js --inputDir "path-to-json-folder" --languages ar,fr
  1. Translate Multiple Languages at Once
node translate-json.js --input "path-to-json-file" --languages fr,es,ar