AI TokenizerA Visual Studio Code extension that counts the tokens in a file or in a piece of text. Load a file or paste some text, pick a model, and the panel reports the count for that model's tokenizer — useful when a prompt or a document has to fit into a context window. Three providers are supported, and they do not work the same way:
What is sent whereGPT counting is entirely local. The text never leaves your computer, and the extension works offline. Counting with Claude or Gemini sends the loaded text to the provider. There is no local tokenizer for those models, so counting means calling their API: the whole text goes to Anthropic or to Google over HTTPS, along with your key. The extension asks for confirmation the first time you count with each of them, and remembers the answer. Nothing else is sent anywhere. There is no telemetry, no analytics, no update
check and no other network traffic. The panel itself is sealed off: its Content
Security Policy is The text you load is not written to disk, to settings, to workspace state or to any log. It lives in the open panel and disappears with it; the Clear button empties it immediately. API keysRun AI Tokenizer: Set API Key — or press Paste a key in the panel — and
paste the key into the masked prompt. It goes straight into the editor's
encrypted secret storage: never into The panel shows whether a key is stored for the selected provider, and AI Tokenizer: Clear Stored API Keys removes both. Secret storage is shared between editor profiles, so a key set once works everywhere — and clearing it clears it everywhere.
Usage
While the panel is open it follows the editor: whatever file you switch to is loaded into it, replacing what was there. That is what makes dragging work. VS Code claims a dropped file before any panel can see it and opens it as an editor tab; the panel then takes that file over — it loads the content and closes the tab again, so the file ends up counted rather than opened. A file opened for reading, one with unsaved changes, and one that has been open for more than a moment are loaded but never closed. Text you typed or pasted is replaced the same way, so paste into the panel when no file is going to be opened next, or count it before switching files. The panel also shows a character and word count, computed locally as you type. For GPT models the result includes the token breakdown: the text split into the pieces the tokenizer produced, coloured in sequence, with a switch to the raw token IDs. Claude and Gemini return a number only — their APIs do not expose the individual tokens — so there is nothing to colour there. If the model you need is not in the list, choose Other model ID... and type the identifier. Model lists change faster than releases do. What the numbers meanA token count is only as good as the tokenizer behind it. Claude and Gemini counts come from the provider's own endpoint, so they match how that provider will count the same text. Both APIs count a complete request, so the number includes the small overhead of the message structure around your text, not the characters alone. GPT counts are computed locally from the encoding table that What it does not doIt does not send anything to a model, does not estimate cost, does not count images or other non-text content, and does not verify that a model identifier is real before asking the provider about it. Files above 10 MB are refused, because counting them would freeze the panel. InstallationInstall "AI Tokenizer" from the Visual Studio Code Marketplace, or download a
Feedback and security
Development
To try the extension, open this folder in VS Code and press License |
