Skip to main content

Convert JSON (i18next) to Android strings.xml — flat keys, escaping, and resource naming

Free CLI to convert i18next-style JSON locale files into Android strings.xml. Handles key naming, escaping, and ordering for Android resource files.

Free CLI — convert i18next files to android-xml:

npm install -g @i18n-agent/i18n-convert
Need to translate, not just convert? Try i18nagent.ai MCP →

JSON locale files are the lingua franca of web i18n libraries (i18next, react-intl, vue-i18n, next-intl), but Android wants a flat XML resource file with strict naming rules — no dots, no hyphens, lowercase-underscore only. Going from JSON to Android XML therefore is not just a format conversion: it is a key-validation and ordering problem. Most online converters either crash on unfamiliar values or emit non-deterministic key ordering, which makes diffs noisy and code review painful.

i18n-convert reads i18next-style JSON, validates that each key conforms to Android's ^[a-z][a-z0-9_]*$ resource naming rule, and emits a strings.xml document with <string> elements sorted lexicographically by key so that the output is deterministic across runs. Standard XML escaping is applied to string content automatically. The fixture below is the canonical simple.json from the project's own test suite — three flat keys mapping directly to Android string resources. Notice how the output reorders the entries alphabetically (app_title, goodbye, welcome) regardless of the input order, which keeps your version-control diffs minimal. This page shows the exact command and the verbatim output produced by the latest CLI build.

Command

i18n-convert simple.json --to android-xml -o strings.xml

Input

{
  "welcome": "Welcome to our app",
  "goodbye": "See you later",
  "app_title": "My Application"
}

Output

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="app_title">My Application</string>
    <string name="goodbye">See you later</string>
    <string name="welcome">Welcome to our app</string>
</resources>

Related conversions