Home / AI Builder / Token Counter

Token Counter

Count tokens with the real GPT-4o, GPT-4, Llama 3, Mistral, Qwen, Gemma or DeepSeek tokenizer, see each token, context use and cost.

Free, no uploads, no sign-up. Runs 100% in your browser.

How Token Counter works

Everything runs in your browser. Prompts, datasets and model files are never uploaded. The tokenizer file for the model you pick (1 to 8 MB, from the Hugging Face Hub) is loaded by Transformers.js in a Web Worker, then your text is encoded exactly as the model would see it. Quick estimate mode uses about 4 characters per token with no download.

Input: Text, TXT, MD, JSON. Output: Text.

How to use Token Counter

  1. Paste your prompt or drop a text file.
  2. Pick the tokenizer for your model.
  3. Read the token count, context share and the coloured token view.
  4. Enter your prices per million tokens to see the cost.

Tips

  • Different models split the same text differently, so always count with the tokenizer of the model you call.
  • Non English text and code usually need more tokens per word.

Token Counter FAQ

Why does my count differ from the number the API bills?
APIs add a few tokens of their own for each message (role markers and the reply start), and tool or image inputs are counted separately. The count here is the text you paste, encoded with the real tokenizer, so it matches the prompt part exactly.
Is the Claude count exact?
No. Anthropic has not published the tokenizer of its current models. The Claude option uses the older public tokenizer, so treat it as an estimate.
Why is the first run slower?
This tool needs a processing engine that is downloaded once and then cached: Transformers.js tokenizers: one tokenizer file of 1 to 8 MB from the Hugging Face Hub the first time you pick a model, then cached. Only the engine is downloaded. Your file never leaves your device.
Are my files uploaded?
No. This tool runs entirely in your browser tab. Files are read from your disk into memory and the result is generated locally.
Is it free? Are there limits or watermarks?
Free and open source (MIT). There are no file-size caps, daily quotas, accounts or watermarks.
Does it work offline?
Yes, once the page (and any engine it needs) has loaded, it keeps working without a connection thanks to the service worker cache.

Related tools

  • RAG Text Chunker: Split documents into overlapping chunks by characters, words or tokens for embeddings and RAG, then export JSONL, JSON or CSV.
  • Fine-tune Dataset Checker: Validate a JSONL fine-tuning file line by line: roles, empty replies, duplicates, token limits, then download clean train and validation splits.
  • Word Counter: Words, characters, sentences, reading time and keyword density.
  • MCP Config Builder: Build Model Context Protocol server configs for Claude Desktop, Cursor, VS Code, Windsurf, Claude Code and Gemini CLI, or convert one app's config to another.

OpenFile runs in your browser. Turn on JavaScript to use the tools.