Estimate before you call the API

GPT & Claude Token Counter

Paste any prompt or document and instantly see an estimated GPT and Claude token count — plus characters, words and approximate API cost. Stay under context limits and budget prompts with confidence. Runs 100% in your browser; your text never leaves the page.

Counts are a fast client-side BPE approximation, typically within a few percent of official tiktoken / Claude tokenizers for English prose. Use the official tokenizer for billing-critical counts.
0
GPT tokens (est.)
0
Claude tokens (est.)
0
Words
0
Characters
0
Chars (no spaces)

✍️ Your text

💰 Approximate cost

Public list prices for the input side of a single call. Output tokens are billed separately and are usually pricier.
$0.000000
Estimated input cost

What is a token, and why count them?

Large language models do not read words — they read tokens. A token is a chunk of text, usually a word fragment of roughly three to four characters of English, produced by a byte-pair-encoding (BPE) tokenizer. Common short words like "the" or "and" are a single token; longer or rarer words split into several. Crucially, everything about working with an LLM is measured in tokens: your prompt's length, the model's reply, the size of its context window, and the bill. If you build with or write prompts for GPT or Claude, knowing the token count of your text is the difference between a request that succeeds cheaply and one that gets truncated, errors out, or quietly costs more than you expected.

This token counter gives you that number instantly. Paste any text and it estimates the GPT and Claude token counts as you type, alongside character and word counts and an approximate input cost for the model you select. It is the quick gut-check you reach for before pasting a long document into a prompt, before shipping a prompt template, or when debugging why an API call hit a context-length limit.

How this token counter works

The exact tokenizers used by OpenAI (tiktoken, with the o200k_base vocabulary for GPT-4o and newer) and by Anthropic for Claude rely on large learned merge tables — megabytes of vocabulary data. Shipping and running those in the browser for a quick estimate is overkill. Instead, this tool uses a fast BPE-style approximation: it splits text into the same kinds of atoms a real encoder sees — runs of letters, runs of digits, individual punctuation marks, and whitespace — and then applies per-atom token costs calibrated to match real tokenizer behavior. Words are merged into sub-word tokens at a rate close to the real vocabularies (GPT merges slightly more aggressively than Claude), digit runs are chunked, and non-Latin characters such as CJK and emoji are counted as costing more, which mirrors how real encoders behave.

The result is an estimate, and it is labeled as one throughout the interface. For ordinary English prose it typically lands within a few percent of the official counts — more than good enough for prompt budgeting and context-window checks. Where it can drift is dense source code, languages with non-Latin scripts, unusual Unicode, or text that is mostly punctuation. For those, or when you need an exact number for billing reconciliation, run the text through the official tokenizer. The counting happens entirely in your browser, so your prompts and documents are never uploaded.

Token rules of thumb

Staying within the context window

Every model has a maximum context window — the combined token budget for your input plus the model's output. GPT-4o offers 128K tokens; Claude 3.5 Sonnet offers 200K. The context-fit bars in the tool show, at a glance, how much of each window your current text would consume on the input side. This matters because the input and output share one budget: if you fill 120K of a 128K window with input, you have left almost no room for the answer. Counting first lets you trim, chunk, or pick a larger-context model deliberately rather than discovering the limit through a failed call.

Pair it with the rest of the AI toolkit

Counting tokens is one piece of operating in the AI-era web. If you run a website, decide how AI models may use your content with our AI robots.txt generator, and hand them a clean map of your best pages with an llms.txt file. Building an app that calls models directly? You will likely also want our sister developer utilities at fmt.hjlabs.in — a JSON formatter for inspecting API responses and a JWT decoder for debugging auth tokens. All of it is free and runs client-side.

Token Counter FAQ

What is a token? +
The unit LLMs read and bill in — usually a word fragment of about 3-4 characters of English. Models split text into tokens with a BPE tokenizer; both input and output are priced in tokens, not words.
How accurate is this counter? +
It is a fast client-side BPE approximation, typically within a few percent of official tiktoken / Claude counts for English prose. Code, non-Latin scripts and heavy punctuation vary more. It is labeled an estimate; use the official tokenizer for billing-critical counts.
How many tokens is a word? +
About 1.3 tokens per English word on average; 100 tokens is roughly 75 words. A 1,000-word document is around 1,300 tokens.
Is my text uploaded anywhere? +
No. All counting runs in your browser with JavaScript. Your prompts and documents are never uploaded, logged or transmitted.
Why do GPT and Claude differ? +
Each model family uses its own tokenizer vocabulary, so identical text splits into slightly different token counts. This tool estimates both separately.