Live LLM Token Counter is a Visual Studio Code extension for prompt writers, AI app builders, and model evaluators who need local token feedback while editing. It shows live token counts for a selection or the whole document, lets you switch tokenizer families from the status bar, and can paint token boundaries directly over the editor text.
The extension identifier and settings namespace are gpt-token-counter-live so existing users keep their installs and settings.
Tokenizer support is provided by tiktoken for GPT/OpenAI models, Anthropic's tokenizer for Claude, a local Gemini approximation, and @huggingface/tokenizers for HuggingFace tokenizer.json files such as Qwen, Llama, and Mistral.
Live token counting for the current selection or entire document, displayed directly in the status bar. Counts update automatically as you type or change your selection.
Click the status bar to switch between model families: GPT (OpenAI), Claude (Anthropic), Gemini (Google AI), or HuggingFace.
- GPT (OpenAI): Uses tiktoken
encoding_for_model('gpt-5')with fallbacks too200k_base→cl100k_basefor accurate token counting across all GPT models. - Claude (Anthropic): Uses Anthropic's official tokenizer for precise token boundaries with full highlighting support.
- Gemini (Google AI): Approximates tokens using GPT encodings or ~4 chars/token fallback (highlighting not available).
- HuggingFace: Loads a
tokenizer.jsonfrom the Hub (or a local file) and reuses it for live counts. Byte-level BPE tokenizers (Qwen, Llama, Mistral, etc.) support highlighting; SentencePiece tokenizers that alter whitespace fall back to counting only.
See your tokens in real-time with rotating color bands that show exactly where each token begins and ends. Available for GPT, Claude, and HuggingFace byte-level BPE tokenizers (Qwen, Llama, Mistral, etc.).
Key features:
- Toggle on/off: Click the palette icon in the status bar to enable or disable highlighting.
- Smart text contrast: Highlight text automatically adapts to the visible color against the active editor theme; fully transparent highlights preserve the editor's existing text colors.
- Customizable colors: Choose your own colors with alpha/transparency support.
- Editor-aware: Only highlights in text editors; Output and Debug panes remain clean.
Open the Command Palette and run Configure Token Highlight Colors to customize the rotating token color palette.
Features:
- Add, remove, and reorder palette colors
- Apply the 8-color preset
- Color pickers with opacity sliders
- Live token-style preview of the full palette cycle
- Dragging color and opacity controls previews locally; changes apply to editor highlighting on release
- The existing two-color palette remains the default; the 8-color palette is available as an opt-in preset
- Reset to the default two-color palette at any time
Personalize how token information appears in your status bar using template placeholders.
Supported placeholders:
{count}- Token count{family}or{model}- Model family name (GPT, Claude, Gemini, HuggingFace){provider}- Provider name (openai,anthropic,gemini,huggingface)
- Visual Studio Code
1.82.0or newer, or a compatible editor that installs extensions from the Open VSX Registry.
This extension provides the following commands (accessible via Command Palette):
-
Change Model Family: Switch between GPT (OpenAI), Claude (Anthropic), Gemini (Google AI), and HuggingFace tokenizers. Also accessible by clicking the token count in the status bar. -
Toggle Token Highlighting: Enable or disable visual token highlighting overlays. Also accessible by clicking the palette icon in the status bar. -
Configure Token Highlight Colors: Open an interactive palette editor to add, remove, reorder, and customize up to 8 token highlight colors with a live preview. -
Count Tokens: Manually trigger token counting for the current document or selection. -
Refresh HuggingFace Tokenizer Cache: Clear and reload the configured HuggingFace tokenizer cache.
This extension contributes the following settings:
-
gpt-token-counter-live.defaultModelFamily: Choose which model family activates by default when you open VS Code.- Options:
openai,anthropic,gemini, orhuggingface - Default:
openai
- Options:
-
gpt-token-counter-live.statusBarDisplayTemplate: Customize how token information appears in the status bar.- Default:
Token Count: {count} ({family}) - Supported placeholders:
{count},{family},{model}(alias for family),{provider}
- Default:
-
gpt-token-counter-live.enabledFilePatterns: Glob patterns for files where the status bar should be shown.- Default:
[](empty array shows for all files) - Example:
["*.md", "*.mdc"]shows only for markdown files
- Default:
Select HuggingFace (huggingface) in the model family picker, then point the extension at a tokenizer with either of the settings below. The first load fetches tokenizer.json from the Hub and caches it under the extension's global storage directory, so subsequent launches are offline-friendly.
gpt-token-counter-live.huggingfaceModelId: HuggingFace repo ID (e.g.Qwen/Qwen2.5-7B-Instruct,meta-llama/Llama-3-8B,mistralai/Mistral-7B-Instruct-v0.3). The extension fetcheshttps://huggingface.co/{id}/resolve/main/tokenizer.jsonplustokenizer_config.jsonand caches them on disk.gpt-token-counter-live.huggingfaceTokenizerPath: Absolute path to a localtokenizer.jsonfile. When set, it overrideshuggingfaceModelId. A siblingtokenizer_config.jsonwill be picked up automatically if present.
What works and what doesn't:
- Byte-level BPE tokenizers (Qwen, Llama, Mistral, most GPT-style tokenizers on the Hub) give precise token counts and highlighting.
- SentencePiece / Unigram tokenizers that strip or transform whitespace (T5, some BERT variants) still give precise counts, but highlighting is automatically disabled. Decoding an id sequence back to text doesn't produce an identical string, so offsets can't be attributed reliably. You'll see token counts but no color overlays.
- Gated or private repositories cannot be fetched without auth. The first load will surface the raw HTTP status in a VS Code error notification (typically
401or403); downloadtokenizer.jsonmanually and pointhuggingfaceTokenizerPathat it. - Missing repositories / offline first-load show the same error notification and fall back to a rough
~4 chars/tokenapproximation until the tokenizer resolves.
Token highlight colors are stored as an ordered palette in your VS Code global state (synced across devices if you have Settings Sync enabled). Tokens cycle through the palette in order. To customize it, select Configure Token Highlight Colors from the Command Palette.
Quick toggle: Click the palette icon in the status bar to enable/disable token highlighting instantly.
There are currently no known issues. If you encounter a problem, please report it on the issue tracker.
See CHANGELOG.md for the complete version history and release details.




