Skip to content

Latest commit

Β 

History

9 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Token Meter for VS Code

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.

counter

πŸ‘‡

Token Meter in action

Count tokens in the selected code:

counter

πŸ‘‡

Token Meter for a small section

πŸ€” Motivation

I was creating some Claude Code Skills. To avoid filling the context window, I needed to evaluate my skill size.

🎨 Features

  • 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

πŸš€ Install

Via marketplace

Via VSCode cli

code --install-extension samber.vscode-token-meter

Via Cursor cli

cursor --install-extension samber.vscode-token-meter

βš™οΈ Settings

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:

["*"]

🀝 Contributing

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.

πŸ‘€ Contributors

Contributors

πŸ’« Show your support

Give a ⭐️ if this project helped you!

GitHub Sponsors

πŸ“ License

Copyright Β© 2022 Samuel Berthe.

This project is under MIT license.

Sponsor this project

Used by

Contributors

Languages