Text

Token Counter

Count characters, words, lines and UTF-8 bytes exactly, and get a clearly labelled estimate of tokens for plain text, Markdown, JSON or code. By default no model tokenizer is used, so token figures are estimates; an optional download adds exact counts for two OpenAI encodings. Your text stays in your browser and is never sent to any AI service.

Guide: Count LLM Tokens: Estimates, Exact Counts and JSON Cost

Ready. Paste or type text to count it.

Counts

Content type: Plain text (auto-detected)

Characters
0
Characters excluding whitespace
0
Grapheme clusters
0
Words
0
Lines
0
Bytes (UTF-8)
0

Characters are Unicode code points, so an emoji is 1 character. Grapheme clusters are what a reader sees as one character (a family emoji is 1 grapheme but 5 code points). Whitespace means spaces, tabs, line breaks and other Unicode spaces.

Estimated tokens

0

Plausible range: 0 to 0

This is an estimate, not an exact token count. No model’s tokenizer is used for this estimate (an optional exact count for two OpenAI encodings is offered further down). Real counts differ by model and can be tens of percent higher or lower, and more so for non-English text, emoji and unusual content.

Optional download, once. It runs in your browser.

Common rules of thumb for comparison with the estimate
Rule of thumbEstimated tokens

How this estimate was calculated

Each character is put in a class and multiplied by an approximate tokens-per-character weight for the chosen content type. The weights are rough, hand-tuned values, not measurements of any specific model.

Character classes, their counts and estimated token contribution
Character classCountTokens per characterEstimated tokens

Exact count for OpenAI encodings (optional)

Nothing is downloaded until you click the button, or until you tick the box below to load it automatically next time. The tokenizer runs in your browser from this site’s own files, and your text is never sent anywhere. Exact for OpenAI encodings only: for every other vendor the figures above remain estimates.

Not loaded. The estimate above is used.

tiktoken’s model table lists o200k_base for GPT-4o and cl100k_base for GPT-4 and GPT-3.5. Which encoding newer models use is not confirmed here. Special tokens such as <|endoftext|> are counted as ordinary text.

Model, cost and context window

Prices and context windows are entered by hand from vendor documentation and change often. Verify on the vendor page.

Exact counts and estimates

Characters, characters excluding whitespace, grapheme clusters, lines and UTF-8 bytes are exact for the text in the box. Words depend on a definition: where the browser supports it, words are found with Unicode word segmentation, which also splits Chinese and Japanese text that has no spaces; otherwise they are runs of non-whitespace characters. Tokens are different: the number of tokens depends on the specific model’s vocabulary, and the estimate does not use one. An optional exact tokenizer for OpenAI’s o200k_base and cl100k_base encodings can be loaded further down the page; it is exact only for those two encodings.

Exact mode, model table and cost

The optional exact tokenizer implements byte-pair encoding for OpenAI’s o200k_base and cl100k_base encodings using the published tiktoken rank tables (MIT licence, stored on this site). It downloads only when you click a button (or on later visits, if you tick the box to load it automatically on this device), runs in a background worker, and never sends your text anywhere. Once it is loaded, the Token view shows the first 1,000 tokens of a text of up to 20,000 characters as coloured segments with their token IDs, so you can see exactly where the tokenizer splits your text. It is exact for those encodings only. Anthropic, Google and other vendors use different tokenizers, so their figures stay estimates. The model table lists context windows and prices that were entered by hand from each vendor’s documentation on the date shown; cost is tokens multiplied by the price per million tokens, with the assumptions shown, and a value that could not be confirmed is shown as unknown.

For valid JSON the page also shows the same data as compact JSON, pretty JSON, TOON and YAML with character counts and token counts side by side. Token differences between formats are only reliable with the exact tokenizer; with estimates they are rough. Limits: exact counting accepts up to 5 million characters, and the TOON and YAML conversion runs only for JSON up to 150,000 characters.

How the token estimate works

The estimate multiplies the count of each kind of character by a rough tokens-per-character weight: about a quarter of a token for English letters, more for digits and punctuation, about one token per Chinese, Japanese or Korean character, several for an emoji, and so on. Code and JSON use heavier weights for punctuation and line breaks than prose does. The tool also shows two common rules of thumb for comparison, characters divided by 4 and words divided by 0.75, and a plausible range around the estimate.

Limitations

  • The weights are approximations tuned for typical English prose and source code. They are not calibrated to any model, so treat the number as an order of magnitude with a margin of error.
  • Non-English text is the least reliable. Urdu, Arabic, Hindi, Chinese, Japanese, Korean and emoji are tokenized very differently across models, and newer tokenizers are often more efficient than older ones. The range widens automatically when much of the text is not Latin script.
  • Real systems add tokens that never appear in your text: message framing, system prompts, tool definitions and images.
  • Content type affects the estimate. Auto-detection is a guess from the text; choose the type yourself if it is wrong.
  • Line breaks in the box are normalised to a single newline. A Windows file with CRLF endings is one byte per line larger on disk than the byte count shown. When you open a file, its size on disk is shown separately.
  • Very long texts: above 500,000 characters, grapheme and word segmentation are skipped and words are counted by whitespace to keep the page responsive.

JSON sizes

When the text is valid JSON, the tool shows its size as written, with all optional whitespace removed (compact) and pretty-printed with a 2-space indent. Strings and numbers are copied exactly as written, so large numbers and key order are never changed. Sending compact JSON to an API usually uses fewer bytes and tokens than pretty JSON.

Privacy

All counting and estimating happens in your browser. Your text is not uploaded, not sent to any AI API and not saved. Downloaded reports contain only the numbers, never your text.

Share this tool

Your data is not included in this link.