Skip to content

CLI Reference

Usage

Terminal window
koto [command] [options]

If no command is provided, koto translate runs by default.


Commands

koto init

Interactive setup wizard. Auto-detects your framework, locale file format, and source directory, then generates a koto.config.ts.

Terminal window
npx koto init
FlagDescription
--yes, -yAccept all defaults without prompting

koto translate

Translate all pending strings. Default command when none is specified.

Terminal window
npx koto translate
npx koto translate --locale es,fr
npx koto translate --context legal
npx koto translate --dry-run
npx koto translate --force
FlagDescription
--locale, -lTranslate only specific locales (comma-separated)
--context, -cTranslate only files matching a specific context profile
--dry-runPreview what would be translated without writing files
--forceRe-translate all keys, ignoring cache and lockfile
--fail-on-errorExit with code 1 on translation errors or quality failures
--jsonOutput results in machine-readable JSON

koto diff

Show what needs translation. Lists new, changed, and deleted keys across all target locales.

Terminal window
npx koto diff
npx koto diff --json
FlagDescription
--jsonOutput diff in machine-readable JSON
--locale, -lCheck only specific locales

koto types

Generate TypeScript type definitions from your source locale files.

Terminal window
npx koto types
npx koto types --watch
FlagDescription
--watchWatch source files and regenerate types on change

koto validate

Check your configuration and test the provider connection.

Terminal window
npx koto validate
npx koto validate
Config file: koto.config.ts (valid) Source locale: src/locales/en.json (214 keys) Target locales: es, fr, de, ja Provider: openai / gpt-4o-mini (connected) Context profiles: default, marketing, legal

koto badge

Generate an i18n coverage badge from your lockfile, plus coverage artifacts for CI and dashboards.

Terminal window
npx koto badge
npx koto badge
i18n Coverage Report Overall: 92% across 6 locales Add to your README: ![i18n](https://img.shields.io/badge/...) Coverage artifacts: koto-coverage.json koto-coverage.html

koto contribute

Fork an OSS repo, run koto translation for one locale, and open a pull request via GitHub CLI.

Terminal window
npx koto contribute owner/repo --locale fr
npx koto contribute owner/repo --locale ja --dry-run
FlagDescription
--locale, -lTarget locale code for the contribution (required)
--dry-runShow steps without creating a fork/PR

koto cache stats

Display cache analytics: cached translations, hit rate, and disk usage.

Terminal window
npx koto cache stats
npx koto cache stats
Cache statistics Location: node_modules/.cache/koto Translations: 1,247 Hit rate: 94.2% Disk usage: 2.3 MB

koto cache clear

Clear the translation cache. Subsequent runs will re-translate all keys.

Terminal window
npx koto cache clear

Global options

FlagDescription
--version, -vShow koto version
--help, -hShow help text

Exit codes

CodeMeaning
0Success
1Translation failure, quality gate failure, or invalid config
2Unknown command or missing required arguments

Environment variables

VariableDescriptionRequired by
OPENAI_API_KEYOpenAI API keyprovider.name: 'openai'
ANTHROPIC_API_KEYAnthropic API keyprovider.name: 'anthropic'
GOOGLE_API_KEYGoogle Gemini API keyprovider.name: 'google'
KOTO_CONFIGCustom path to config fileAll (optional)

koto loads .env files from your project root automatically.


Examples

Terminal window
# Initialize a new project
npx koto init
# Translate everything
npx koto translate
# Translate only Spanish and French
npx koto translate -l es,fr
# Translate only legal context
npx koto translate -c legal
# Preview without writing
npx koto translate --dry-run
# Re-translate everything from scratch
npx koto translate --force
# CI mode: fail on errors
npx koto translate --fail-on-error
# Check what needs translating
npx koto diff
# Generate TypeScript types
npx koto types
# Watch mode for types
npx koto types --watch
# Verify setup
npx koto validate
# Generate coverage badge
npx koto badge
# Contribute translations to an OSS repo
npx koto contribute owner/repo --locale fr