AI Token Counter

Count exact GPT tokens with real tokenizers and estimate what a prompt will cost. 100% free, no signup. Everything runs in your browser.

100% free No sign-up Private by design Works on any device
AI Token CounterRuns locally

Loading the tool…

This free AI token counter tells you exactly how many tokens your text becomes, using the same BPE tokenizers the models actually use: cl100k_base for the GPT-3.5 and GPT-4 era models, and o200k_base for GPT-4o and newer. These are not estimates from a words-times-1.3 formula; the real tokenizer runs in your browser and gives you the true count, alongside plain word and character totals. Your text never leaves your machine.

I built this while debugging why my API bills did not match my guesses, and the answer was that guessing token counts is hopeless: punctuation, code, and unusual words all tokenize in surprising ways. The cost estimator underneath the counter multiplies your counts by per-million-token prices in a table you can edit, because I refuse to hard-code prices that model providers change several times a year. Presets get you started; the edit fields keep the tool honest over time.

How to use

  1. Paste your prompt, document or transcript into the text box.
  2. Read both counts: the tool runs cl100k_base and o200k_base side by side, so you see the number for GPT-4 era models and for GPT-4o and newer at once.
  3. Read the exact token count, along with word and character totals for context.
  4. Scroll to the cost estimator and choose a pricing preset, or type the current per-million-token input and output prices from your provider.
  5. Compare the cost line for each model row; edit the model names and prices so the table matches whatever you actually use.
  6. Adjust your text and watch the count update, trimming until the prompt fits your budget or context window.

Why use our ai token counter?

Exact counts change how you work with context windows. When you know a document is 6,834 tokens rather than roughly seven thousand, you can pack a context window confidently instead of leaving safety margin you did not need, or worse, overflowing it and getting a truncated response. The counts here match what the API will bill because it is the same tokenization.

Running the real tokenizer locally is the honest way to build this. Plenty of token counters approximate from character counts and drift badly on code, URLs and non-English text. This tool ships the actual BPE vocabulary to your browser and encodes your text with it, the same method behind OpenAI's own tokenizer page, so you can verify the numbers yourself.

The editable price table is a small feature I am oddly proud of. Hard-coded prices rot within months, and a cost estimate built on stale prices is worse than none. Presets give you a starting point, and when a provider changes rates you type the new number and the tool is current again, no update required on my end.

Privacy matters more here than almost anywhere else on this site. Prompts contain proprietary product plans, customer transcripts and unreleased copy. Because the tokenizer runs entirely in your browser, you can count a confidential document with the network tab open and watch nothing leave.

The word and character counts alongside tokens build intuition over time. After a few weeks of glancing at the ratio, you start sensing that English prose runs about three quarters of a token per word while dense code runs far higher. For plain writing without the API angle, the word counter is the simpler companion.

Who is this tool for?

Developers budgeting API features use it to price a workflow before writing code. Paste a representative prompt, add a typical completion length, set current prices, and you know whether the feature costs pennies or real money at scale. I did exactly this before adding an LLM step to one of my own projects, and the estimate changed the design.

Prompt writers use it to trim system prompts. When the same instruction block is sent with every request, every wasted token is a recurring cost, and cutting 300 tokens from a prompt used a million times a month is a measurable saving. The live count makes the editing loop tight: cut, check, cut again.

Teams doing retrieval or summarization pipelines check whether documents fit their chunk sizes. Paste a chunk, confirm it sits under the limit with room for instructions, and adjust your splitting logic with real numbers. Condensing long inputs first with the text summarizer is a cheap way to fit more meaning into fewer tokens.

Writers and analysts pasting long reports into chat interfaces use the counter to understand why a conversation hit its limit, and what to cut. Structured data is a common culprit; minified JSON tokenizes leaner than pretty-printed, which you can verify yourself after a pass through the JSON formatter.

Frequently asked questions

Is my text sent to a server to be tokenized?

No. The tokenizer vocabulary loads with the page and the encoding runs in your browser. Your text never leaves your machine, which is the point: prompts and documents are often the most confidential text people handle.

Which tokenizer should I choose?

Use o200k_base for GPT-4o and newer OpenAI models, and cl100k_base for the GPT-3.5 and GPT-4 era. If you are unsure, check your model's documentation; picking the wrong one gives counts that are close but not exact.

Do these counts work for Claude models?

Treat them as close estimates. Claude uses its own tokenizer, which differs from OpenAI's BPE vocabularies, so exact counts will vary a little. For budgeting and rough context-window planning the numbers are still useful; for exact Claude billing, rely on the usage figures the API returns.

Why is a token not the same as a word?

BPE tokenizers split text into frequent fragments rather than dictionary words. Common short words are often one token, longer words split into pieces, and punctuation and spaces have their own patterns. English prose averages roughly 1.3 tokens per word, but the ratio swings a lot for code and unusual text.

Why are the API prices editable?

Because providers change them, and a calculator with stale hard-coded prices quietly lies to you. The presets reflect sensible defaults, and the edit fields let you enter today's rates from your provider's pricing page so the estimate stays trustworthy.

Why does my code count so many more tokens than my prose?

Indentation, brackets and rare identifiers fragment into many small tokens. A 500-word essay and 500 words of source code can differ by hundreds of tokens. This is exactly why counting with the real tokenizer beats any words-based estimate.

Does the counter handle non-English text?

Yes, the tokenizers encode any text, but be aware that many non-English languages tokenize less efficiently than English, sometimes dramatically so. The counter shows you the real cost of that difference, which matters when budgeting multilingual applications.

Related tools