Severity: Warning — does not affect exit code or fail CI builds.
Detection Rule
A key is flagged as unused if it:- Exists in the primary locale file (e.g.,
messages/en.json) - Is not referenced in any TSX/JSX file in your codebase
- Is not matched by any
glot-message-keysannotation
What Gets Detected
Keys Not Used Anywhere
Keys that have no correspondingt() call in the codebase:
messages/en.json
Leftover Keys from Refactoring
Keys that were used but removed during code changes:messages/en.json
Output Format
Severity
Warning - Unused keys don’t cause runtime errors, but they:- Increase bundle size (unused translations are shipped to users)
- Make maintenance harder (more keys to manage)
- Can confuse developers about which keys are actually used
How to Fix
Option 1: Remove with glot clean (Recommended)
Preview what will be removed:
clean command:
- Removes unused keys from the primary locale
- Automatically removes them from all replica locales too
- Creates a backup before making changes
Option 2: Start Using the Key
If the key should be used, add it to your code:Option 3: Keep Intentionally
If you’re keeping keys for future use:- Accept the warnings (they don’t fail builds)
- Document why you’re keeping them (add comments)
- Consider using feature flags to conditionally use them
Important Limitations
Dynamic Keys
If your code uses dynamic translation keys, glot cannot determine if a key is truly unused:glot clean will refuse to run to prevent accidental deletion of keys that are actually used dynamically.
Solution: Use glot-message-keys annotations to declare dynamic keys:
glot clean will know these keys are used and won’t remove them.
Conditional Usage
Keys used in conditional code might appear unused if that code path wasn’t analyzed:sourceRoot, it won’t be detected.
Configuration
Source Root
Make sure yoursourceRoot includes all files that might use translations:
.glotrc.json
Ignore Patterns
You can exclude specific directories from scanning:.glotrc.json
Related Checks
Unused vs Orphan
Don’t confuse these two checks:| Check | What it finds | Severity |
|---|---|---|
unused | Keys in primary locale not used in code | Warning |
orphan | Keys in replica locales not in primary locale | Warning |
messages/en.json (primary)
messages/zh.json (replica)
common.unusedis flagged byunused(in primary but not used in code)common.extrais flagged byorphan(in replica but not in primary)
Examples
Before and After Cleanup
Before and After Cleanup
Before cleanup:Code only uses:After running All unused keys removed, keeping only what’s actually used.
messages/en.json
glot clean --apply:messages/en.json