A VS Code extension that counts tokens in the current file or selected text.
Token count is displayed in the status bar and updates in real-time as you type or change selection.
Count token in the selected code:
I was creating some Claude Code Skills. To avoid filling the context window, I needed to evaluate my skill size.
- Token count for the entire file or selected text
- Real-time updates with debouncing
- Configurable model for tokenization
- File pattern filtering to control which files show token counts
- Click the status bar item to quickly switch models
- VSCode: https://marketplace.visualstudio.com/items?itemName=samber.vscode-token-meter
- Cursor: https://open-vsx.org/extension/samber/vscode-token-meter
code --install-extension samber.vscode-token-metercursor --install-extension samber.vscode-token-meter| Setting | Default | Description |
|---|---|---|
tokenMeter.model |
gpt-4o |
Model to use for token counting. Supported: gpt-4o, gpt-4o-mini, gpt-4-turbo, gpt-4, gpt-3.5-turbo, text-embedding-3-small, text-embedding-3-large, text-embedding-ada-002 |
tokenMeter.filePatterns |
See below | Glob patterns for files to count tokens in. Use ["*"] to match all files. |
Default file patterns:
["*.md", "*.txt", "*.py", "*.js", "*.jsx", "*.ts", "*.tsx", "*.json", "*.yaml", "*.yml", "*.toml", "*.xml", "*.html", "*.css", "*.scss", "*.less", "*.go", "*.rs", "*.java", "*.kt", "*.scala", "*.c", "*.cpp", "*.h", "*.hpp", "*.cs", "*.rb", "*.php", "*.swift", "*.m", "*.r", "*.R", "*.lua", "*.pl", "*.sh", "*.bash", "*.zsh", "*.fish", "*.sql", "*.graphql", "*.proto", "*.dart", "*.ex", "*.exs", "*.erl", "*.hs", "*.clj", "*.vue", "*.svelte", "*.tf", "*.dockerfile", "Dockerfile"]or:
["*"]- Ping me on Twitter @samuelberthe (DMs, mentions, whatever :))
- Fork the project
- Fix open issues or request new features
Don't hesitate ;)
npm install -g @vscode/vsce
vsce package
code --install-extension vscode-token-meter-*.vsix Press F5 in VS Code to launch the Extension Development Host.
Give a ⭐️ if this project helped you!
Copyright © 2022 Samuel Berthe.
This project is under MIT license.

