LLM Token Counter

Count GPT tokens exactly with OpenAI's o200k and cl100k tokenizers, and see how your text is split into tokens. Runs fully in your browser.

Built & Maintained by the devtoolspack Team

Last updated: September 2026

Tokens
0
Characters
0
Words
Chars / token

Counts are exact for OpenAI models. Claude, Gemini and Llama use different tokenizers, so treat these numbers as an estimate for them.

Why Token Counts Matter

Large language models do not read characters or words. They read tokens, which are chunks of text from a fixed vocabulary. Context windows, rate limits and API prices are all measured in tokens, so knowing the count before you send a prompt tells you whether it fits and what it will cost.

How Tokenization Works

OpenAI models use byte-pair encoding (BPE). Common words such as " the" become a single token, while rare words, code identifiers and many non-English words are split into several. A leading space is usually part of the token, which is why " hello" and "hello" have different IDs. The coloured view above shows exactly where each boundary falls.

  • o200k_base: used by GPT-4o, GPT-4.1, GPT-5 and the o-series reasoning models.
  • cl100k_base: used by GPT-4, GPT-3.5 Turbo and text-embedding-3 models.

Tips for Using Fewer Tokens

  • Minify JSON you send as context; indentation and spaces are tokens too. Try the JSON Minifier.
  • Remove repeated boilerplate and duplicate lines with Remove Duplicates.
  • Put stable instructions first so providers that support prompt caching can reuse them.

Private by Design

Prompts often contain unreleased product details or customer data. This counter runs the tokenizer in your browser, and your text is never uploaded. For plain word and character statistics, see the Word Counter.

How to Count Tokens for an LLM Prompt

  1. Choose an encoding: Pick o200k_base for current GPT models or cl100k_base for GPT-4 and GPT-3.5.
  2. Paste your prompt: Paste the prompt, document or system message into the text box.
  3. Read the count: Check the token count and the highlighted token boundaries below.

Frequently Asked Questions

Is this count exact?

For OpenAI models, yes. It uses the same byte-pair encodings (o200k_base and cl100k_base) as OpenAI's tiktoken. Chat APIs add a few extra tokens per message for role markers, so a full chat request is slightly larger than the raw text count.

Can I use this for Claude, Gemini or Llama?

Only as a rough guide. Each model family has its own tokenizer, so the same text produces a different count. For an exact Claude count, use Anthropic's token counting API, and for Gemini use its countTokens endpoint.

Why does my non-English text use so many tokens?

Tokenizers are trained mostly on English, so other scripts are split into smaller pieces. The newer o200k_base encoding is noticeably more efficient for many languages than cl100k_base. Compare them with the encoding selector.

Is my prompt sent anywhere?

No. The tokenizer is downloaded once as a JavaScript file and runs locally, so your text never leaves your browser.

Cite this Tool

Using this tool for a technical blog, research, or documentation? Copy a pre-formatted citation below to link back to devtoolspack.

APA Citation
devtoolspack. (2026). LLM Token Counter. https://devtoolspack.dev/token-counter
MLA Citation
"LLM Token Counter." devtoolspack, 2026, https://devtoolspack.dev/token-counter.