Skip to content
Toolcroft

LLM Token Counter - Count GPT & Claude Tokens

Developer Tools

Count exact GPT tokens (o200k_base, cl100k_base) plus a labeled Claude estimate. See per-model cost at your own price. Runs entirely in your browser.

Characters
0
Words
0

Token counts

EncodingModelsTokens
o200k_baseGPT-4o, GPT-4.1, o1/o3 (exact)—
cl100k_baseGPT-3.5, GPT-4 (exact)—
Claude (estimate)Claude 3/4/5 family (chars / 3.5)0
Gemini (estimate)Gemini 3.x family (chars / 4)0

Estimated cost (optional)

Preset prices are a point-in-time snapshot verified on 2026-07-17, provided for convenience only - they are not a live feed and are not guaranteed to still be current. Check your provider's own pricing page before relying on these numbers for real budgeting. Token counts feeding the estimate are exact for OpenAI presets (o200k_base) and heuristic character-based approximations for Anthropic and Google presets, and for "Custom" (cl100k_base in paste mode, ~4 chars/token in file-size mode).

How to use this tool

  1. Choose an input mode. Pick "Paste text" to tokenize what you type, or "Estimate from file size" to get a rough estimate from a file size and unit without pasting anything.
  2. Compare token counts. See exact o200k_base and cl100k_base counts side by side with the labeled Claude and Gemini estimates.
  3. Pick a model preset or enter your own price. Select a frontier model preset to auto-fill its input/output price per 1M tokens, or choose "Custom" to enter your own, and see the estimated cost for this text.

What tokens are and why they matter

Large language models don't read text one character at a time - they read tokens, which are common sub-word chunks learned from huge amounts of training text. A short common word like "the" is usually one token; a rarer or longer word like "tokenizer" often splits into several ("token" + "izer"). This matters because every API call to a hosted model is priced and limited by token count, not character or word count, so a prompt that looks short in characters can still be expensive or run over a context window if it's dense with rare words, code, or non-English text.

As a rough rule of thumb, English prose averages around 4 characters per token, but that ratio swings widely: source code, JSON, and other structured text tend to use more tokens per character because of frequent punctuation and short identifiers, while very repetitive text can compress into fewer tokens than the rule of thumb suggests. That variability is exactly why an exact tokenizer, not a character-count estimate, is the only reliable way to know your real token count before sending a prompt.

Why the counts differ between models

This tool counts tokens using the same open-source tokenizer library (gpt-tokenizer) that implements OpenAI's actual encodings, so the o200k_base and cl100k_base counts shown above are exact, not estimated. o200k_base is used by newer OpenAI models (GPT-4o, GPT-4.1, and the o1/o3 reasoning models); cl100k_base is used by GPT-3.5-turbo and GPT-4. The two encodings use different sub-word vocabularies, so the same input text can produce a noticeably different token count between them - o200k_base's larger vocabulary generally tokenizes English and code slightly more efficiently than cl100k_base.

Anthropic does not publish a public tokenizer for Claude models, so the Claude row is clearly labeled as an estimate: characters divided by 3.5, rounded up. That heuristic tracks real Claude token counts reasonably closely for typical English prose, but it will drift for code, tables, or other languages - treat it as a ballpark, not a number to budget a hard context-window limit against.

Worked example: estimating prompt cost

Say you're building a summarization feature that sends a 2,000-character system prompt plus a 6,000-character article to a model on every request. Pasting that combined 8,000 characters into the box above might show roughly 1,900 cl100k_base tokens. At a hypothetical price of $3 per million input tokens, that single request costs about $0.0057 - trivial alone, but at 10,000 requests a day it's roughly $57/day, which is the kind of number worth knowing before you ship. Enter your model's actual per-token price in the cost box to see this math for your own prompts.

Don't have the text handy, or working with a large file you don't want to paste? Switch to the "Estimate from file size" mode and enter a size and unit instead for a rough token estimate. The cost section also includes a dropdown of current frontier model presets across OpenAI, Anthropic, and Google that auto-fill input/output pricing per 1M tokens (or pick "Custom" to enter your own), plus an optional requests-per-day field to project daily and monthly spend, and CSV/PDF export of the full cost breakdown.

Reducing token usage

Technique Why it helps
Trim boilerplate instructions Repeated system-prompt text is billed on every request
Use compact formats (CSV/YAML over verbose JSON) Fewer punctuation characters, fewer tokens per data point
Summarize long context instead of pasting it raw Cuts input tokens dramatically for retrieval-heavy prompts
Shorten variable/field names in structured prompts Long identifiers often split into multiple tokens
Cache or reuse system prompts (where the API supports it) Some providers discount cached repeated prefix tokens

Frequently asked questions

What is a token?

A token is the unit language models actually read and price by, not a word or a character. Tokenizers break text into common sub-word chunks - "tokenizer" might become "token" + "izer", for example - so a rough rule of thumb is about 4 characters per token for English prose, though code, numbers, and non-English text often use more tokens per character.

Why do the counts differ between models?

Different model families use different tokenizers. GPT-4o and newer OpenAI models use the o200k_base encoding; GPT-3.5 and GPT-4 use cl100k_base. Because each encoding has its own vocabulary of sub-word chunks, the same text can split into a different number of tokens depending on which one is used.

Is the Claude token count exact?

No - it is clearly labeled as an estimate. Anthropic does not publish a public tokenizer for Claude models, so this tool approximates the count as characters divided by 3.5 and rounded up, which tends to track real Claude token counts reasonably closely for English prose but can drift for code or other languages.

Does my text get uploaded anywhere?

No. Tokenization runs entirely in your browser using the open-source gpt-tokenizer library. Nothing you paste is sent to a server, logged, or stored.

What's the difference between the two input modes?

"Paste text" tokenizes what you actually type or paste, giving exact o200k_base/cl100k_base counts plus labeled Claude and Gemini estimates. "Estimate from file size" skips pasting entirely - enter a file size and unit to get a rough token estimate for all of the same model families, useful when you don't want to open and paste a large file.

Are the model preset prices always current?

No - preset prices are a point-in-time snapshot, not a live feed, and AI provider pricing changes over time. Check your provider's own pricing page before relying on these numbers for real budgeting.

Browse all developer tools