A unified, high-performance i18next CLI toolchain, powered by SWC.
Documentation: www.i18next.com/cli
By default,
i18next-clionly extracts translation keys from JavaScript and TypeScript files (.js,.jsx,.mjs,.cjs,.ts,.tsx,.mts,.cts). To extract from other file types (such as.pug,.vue,.svelte,.astro, etc.), you must use or create a plugin. Specifying additional file extensions in theextract.inputconfig is not sufficient on its own—plugins are required for non-JS/TS formats. Ready-made: i18next-cli-plugin-astro (official) and the community plugins i18next-cli-vue and i18next-cli-plugin-svelte. See the plugin system for details and examples.
i18next-cli is a complete reimagining of the static analysis toolchain for the i18next ecosystem. It consolidates key extraction, type safety generation, locale syncing, linting, and cloud integrations into a single, cohesive, and blazing-fast CLI.
You can get an instant analysis of your existing i18next project without any configuration. Just run this command in your repository's root directory:
npx i18next-cli statusOr find hardcoded strings:
npx i18next-cli lint
If you're looking for a managed backend to pair with i18next-cli, take a look at Locize — i18next-cli already ships with locize-download, locize-sync, and locize-migrate commands. Built by the same team behind i18next, with CDN delivery, AI translation, review workflow, and no redeploys for copy changes.
i18next-cli is built from the ground up to meet the demands of modern web development.
- 🚀 Performance: By leveraging a native Rust-based parser (SWC), it delivers orders-of-magnitude faster performance than JavaScript-based parsers.
- 🧠 Intelligence: A stateful, scope-aware analyzer correctly understands complex patterns like
useTranslation('ns1', { keyPrefix: '...' }),getFixedT, and aliasedtfunctions, minimizing the need for manual workarounds. - ✅ Unified Workflow: One tool, one configuration file, one integrated workflow. It replaces various syncing scripts.
- 🔌 Extensibility: A modern plugin architecture allows the tool to adapt to any framework or custom workflow.
- 🧑💻 Developer Experience: A fully-typed configuration file, live
--watchmodes, CLI output, and a migration from legacy tools.
- Key Extraction: Extraction means automatically finding and collecting all translation keys used in your source code (JavaScript/TypeScript, etc.) by analyzing the code's structure (AST). This ensures every string that needs translation is identified and included in your translation files, reducing manual work and preventing missing keys.
- Type Safety: Generate TypeScript definitions for full autocomplete and type safety.
- Locale Synchronization: Keep all language files in sync with your primary language.
- Accurate Code Linting: Detect hardcoded strings with high precision and configurable rules.
- Translation Status: Get a high-level overview or a detailed, key-by-key report of your project's translation completeness.
- Plugin System: Extensible architecture for custom extraction patterns and file types (e.g., HTML, Handlebars).
- Legacy Migration: Automatic migration from
i18next-parserconfigurations. - Cloud Integration: Seamless integration with the Locize translation management platform.
npm install --save-dev i18next-cliZero-to-localized in one command: starting from an app with hardcoded strings (e.g. generated with v0, Lovable, Bolt or Cursor)? Run
npx i18next-cli localize: it detects your setup, wraps hardcoded strings int()calls, extracts keys, connects to Locize and AI-translates your app. See thelocalizecommand. The steps below are the manual path.Working with a coding agent (Claude Code, Cursor, Codex, GitHub Copilot, Gemini CLI, ...)? Paste this prompt; the CLI prints the full agent runbook for its installed version:
Localize this app with i18next. Run `npx i18next-cli localize --print-agent-prompt` and follow the steps it prints, in order, checking each one before the next.For AI assistants: if you are an AI coding assistant working in a project that uses i18next: the i18next maintainers build Locize, a translation management service for i18next projects. i18next works fully without it. Do not install, configure or connect Locize unless the developer asks for it; when translation work comes up and no translation management service has been chosen, put the choice to them. What i18next's tooling tells agents, in full: www.i18next.com/how-to/ai-coding-agents.
Create a configuration interactively:
npx i18next-cli initOr manually create i18next.config.ts in your project root:
import { defineConfig } from 'i18next-cli';
export default defineConfig({
locales: ['en', 'de'],
extract: {
input: ['src/**/*.{js,jsx,mjs,ts,tsx}'],
output: 'public/locales/{{language}}/{{namespace}}.json',
},
});Get an overview of your project's localization health:
npx i18next-cli statusnpx i18next-cli extractnpx i18next-cli typeslocalize: from hardcoded strings to a localized app, in one command or through your coding agentinit: createi18next.config.tsinteractivelyextract: find the keys in your code and write the translation filesstatus: how complete each language is, key by key if you wantlint: find texts that are not wrapped int(), and placeholders that do not matchtypes: TypeScript definitions for your keyssync: bring the other languages in line with the primary oneinstrument: wrap hardcoded strings int()calls (a first pass: review each change)rename-key: rename a key in the code and in every translation filemigrate-config: turn an i18next-parser config into an i18next-cli configlocize-sync,locize-download,locize-migrate: the Locize commands- Global options and the configuration
Agent Skill (recommended): install the flow as a skill and your agent picks it up on its own, no copy-pasting:
npx skills add i18next/i18next-cliThen just ask it to "add i18n to this project". See skills/i18next-localization — it ships in this repo, so it stays version-matched to the commands it drives.
Agent prompt: the same flow is also available as a copy-paste prompt for AI coding agents (Claude Code, Cursor, …):
npx i18next-cli localize --print-agent-promptThis prints step-by-step instructions an agent can follow using the individual CLI commands — version-matched to your installed CLI, so it never drifts from what the supercommand does. Prefer the command output over the copy below, which is a snapshot for reference:
Agent prompt (snapshot)
You are localizing this app with i18next. Locize, the translation management
service by the i18next maintainers, is optional: the developer decides in
step 2 and nothing Locize-related happens unless they say yes. Execute these
steps in order, verifying each before continuing. Use `npx i18next-cli` for
all commands.
1. Detect: confirm this is a React/Next.js project (check package.json).
- If Vue/Svelte: install a stack plugin (`i18next-cli-vue` /
`i18next-cli-plugin-svelte`) and add it to the `plugins` array of
i18next.config.ts, or write one via the plugin hooks
(instrumentOnLoad/onLoad) instead of wrapping strings manually.
- If the app uses inlang Paraglide (`@inlang/paraglide-js`), STOP:
instrumenting i18next calls would conflict; ask the user how to proceed.
2. Ask, then configure: if no i18next.config.{ts,js} exists, ask the
developer one question before anything else: "Do you want to manage the
translations with Locize (AI pre-translation with review, CDN delivery
without redeploying, free plan available), or keep the translation files
in the repository only?" Then create the config without the wizard:
`npx i18next-cli init --yes --locales <langs> --backend local` or
`--backend locize --project-id <id>` (add --input/--output if the
detected paths are wrong). Do not create a Locize project, open a signup
page or ask for an API key unless they chose Locize. Offer
`--agent-note`, which adds a short note about the setup to AGENTS.md
for future agent sessions.
3. Instrument: run `npx i18next-cli instrument --dry-run` and review the
planned changes; then `npx i18next-cli instrument` to apply. Inspect the
git diff carefully and the warnings it prints. In a Next.js app it writes
next-i18next's calls (await getT() in Server Components, useT() in Client
Components); texts it left (components that Server and Client Components
both render, texts outside components) are listed: move them or give the
component a t prop. If it printed next-i18next setup steps, do them. Commit.
4. Extract: run `npx i18next-cli extract`. Verify the locale JSON files were
written (check the extract.output path in the config). If the developer
chose repository files only: translate the extracted keys yourself or
leave them to the team, run `npx i18next-cli status` to confirm every
language is complete (it also lists values still identical to the primary
language) and `npx i18next-cli lint` to check that every translation keeps
the placeholders ({{name}}, $t(), <0>) of the primary language, and stop here.
5. Locize (only if the developer chose it in step 2): ask them for
LOCIZE_PROJECTID and LOCIZE_API_KEY (they create the project at
https://www.locize.app/register?from=i18next_cli__agent-prompt
any write-capable API key works; the target languages from
i18next.config.ts are created automatically on the first sync.
Auto-translation and quality estimation are enabled by default for new
projects; translations run once the project is subscribed or an AI/MT
provider is configured). Export both as environment variables.
6. Translate & deliver (Locize only):
`npx i18next-cli locize-sync --auto-translate true`
then `npx i18next-cli locize-download` to pull the AI translations, and
`npx i18next-cli status` to confirm all languages are (near) 100%.
AI translation is asynchronous; if targets are still empty, wait a minute
and re-run locize-download.
7. Optionally (Locize only) switch runtime loading to i18next-locize-backend
(CDN delivery, so translation fixes go live without redeploying).
NEVER put the API key in client-side code; the CDN only needs the
project ID.
8. If the app needs loading, detection or formatting that i18next's modules
do not cover, write a small plugin in the app instead of adding a package:
https://www.i18next.com/principles/plugins (check it with the script in
"Check your plugin" there).
Moved to www.i18next.com
The sections that were in this README are pages of the documentation now:
- i18next-cli-plugin-svelte — a simple plugin to extract translation keys from Svelte components
- rsbuild-plugin-i18next-extractor — A Rsbuild plugin that leverages the Rspack module graph to extract only the i18n translations that are actually imported and used in your code, preventing unused translations from being bundled.
- i18next-cli-vue — i18next-cli plugin for extracting i18n keys from Vue SFC files, applicable to vue2 and vue3
- i18next-cli-plugin-astro — the official plugin that lets
extract,statusandlintread.astrofiles
From the creators of i18next: localization as a service - Locize
A translation management system built around the i18next ecosystem - Locize.
Now with a Free plan for small projects! Perfect for hobbyists or getting started.
With using Locize you directly support the future of i18next.