cjk-token-reducer CLI
A Claude Code hook that translates Chinese, Japanese and Korean prompts to English and cuts 35–50% of tokens.
- 58 ★ on the repository
- Last commit
- MIT
Extended access
Why this level
- The hook reads every prompt and sends its text to an external translation service, with a cache kept on disk.
Install
- Works in
Manual install
cargo install --git https://github.com/jserv/cjk-token-reducerOn macOS add `--features macos-nlp`. Then wire the `UserPromptSubmit` hook in Claude Code settings.
Access and checks
How we reviewExtended accessThe tool runs code or makes network calls and only reads external data.
- The hook reads every prompt and sends its text to an external translation service, with a cache kept on disk.
This is third-party code. Review the repository files before installing.
What it does
`cjk-token-reducer` is a small Rust program that intercepts a prompt before it goes to Claude Code. Chinese, Japanese and Korean text is translated to English, because these languages use two to four times more tokens for the same meaning. The author claims 35–50% savings in input tokens. Code, file paths and URLs are not translated and stay local. English terms in camelCase, PascalCase and SCREAMING_SNAKE_CASE are detected automatically, and on macOS names and titles are additionally caught by Apple NaturalLanguage. Translations are cached on disk. Critical words can be protected with `[[term]]` markers.
Who it is for. Claude Code users who write prompts in Chinese, Japanese or Korean and count tokens.
Good fit when
- Long Chinese prompts eat the context window quickly, and it needs stretching.
- The cost of sessions with CJK text should drop without changing the model.
- The workflow is asynchronous or batch, and a 100–300 ms translation delay does not matter.
- The text holds a lot of code and paths that must reach the model unchanged.
Not a fit when
- Wording precision is needed, as in legal and medical tasks.
- A real-time chat is running where minimal latency matters.
- A model with a good CJK tokenizer is used, for example DeepSeek V3 or Qwen 2.5.
Example request
Enable the cjk-token-reducer hook and write prompts in Chinese: code and paths stay as they are, and the answer comes back in English.Limitations
Prompt text goes to the free Google Translate API without a key, so confidential material is best kept out. Translation loses nuance: terms may shift meaning, and back-translation of the answer sounds unnatural. Latency is 100–300 ms per request, and one to three API calls are affected. Support is verified for Claude Code and GitHub Copilot, the build runs through Cargo, and `make install` installs the binary and the hook. Cache and statistics live in user directories, the cache is kept for 30 days and takes up to 10 MB.
How to disable. Run `make uninstall` in the cloned repository: it removes the binary and the hook. Erase the cache from the user directory by hand.
FAQ
How do I install the program?
Run `cargo install --git https://github.com/jserv/cjk-token-reducer`. On macOS add `--features macos-nlp` for name recognition.
How do I connect it to Claude Code?
Add a `UserPromptSubmit` hook with the `cjk-token-reducer` command to `~/.claude/settings.json`. The program reads prompt JSON from standard input.
What is the response language?
English by default, which gives maximum savings. The `zh`, `ja` and `ko` values of `outputLanguage` ask for an answer in that language, but more output tokens are then spent.
What stays untranslated?
Code blocks, paths and URLs are not translated. Other words are protected by a `[[term]]` marker or automatic detection of English terms.
Where are settings stored?
In the `.cjk-token.json` file: first searched in the current folder, then in the home folder, then in `~/.config/cjk-token-reducer/`.
Discussion
No questions or reviews yet.
Related
CLI toolsAn installer for a set of hooks, commands and plugins that compress tool output and save tokens in Claude Code.
The context-optimizer plugin shows Claude session cost, trims context and hands file reads and tests to cheap Haiku agents.
A Rust program that shrinks the command output an agent reads: drops build and test noise, folds repeated file reads and redacts credentials
Token Savior indexes code by symbol, keeps memory between sessions and rewrites noisy Bash commands so the agent spends fewer tokens
A hundred ready loops for Claude Code, Cursor and Codex: the agent acts, runs a check and fixes the cause until the goal is met.
A CLI that deploys managed Claude Code instructions to a project, previews file changes and can undo the installation.
README in short
The scheme is called translate, compute, translate back. The README lists the trade-offs and the cases where the program is unnecessary. Threshold, cache and term preservation are set in `.cjk-token.json`.