Skip to content

samber/vscode-token-meter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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.

Token Meter in action

Count token in the selected code:

Token Meter for a small section

🤔 Why ?

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.

Contributors