LLM token counter

Count GPT-4o and GPT-4 tokens online. Compare o200k_base and cl100k_base, inspect token pieces and estimate input cost locally in your browser.

49 / 200,000 characters · plain-text encoding, including literal special-token strings.

Loading the local tokenizer…

—tokens
49characters (UTF-16)
7words
—chars per token

Token pieces

Token counting runs in a worker on your device without uploading text. These are exact counts for the selected encoding, not a complete chat-request bill. Other providers use different encodings. A replacement symbol can appear when one token contains only part of a Unicode character.

About this tool

Paste text to compare OpenAI’s GPT-4o and GPT-4 encodings, inspect token pieces and estimate input cost. Counts are exact for plain text in the selected encoding; chat message framing and tool definitions add tokens.

What you can do

  • Check whether a prompt fits a context window
  • See how code, emoji and other languages split into tokens
  • Estimate input cost from your provider’s price per million tokens
  • Compare the two common OpenAI encodings

All tools · LLM API exercises · Free demo API

Frequently asked questions

What is a token?

A token is a piece of text, often part of a word, that a language model reads and writes. Providers measure limits and pricing in tokens, not characters or words.

Are these counts exact for Claude or Gemini?

No. The counts are exact for OpenAI’s o200k_base and cl100k_base encodings. Other providers use different tokenizers, so use these numbers as a rough guide for them.

Is my text sent anywhere?

No text is uploaded to count tokens. The tokenizer runs in a worker on your device.

Why do chat requests use more tokens than my text?

Chat formats add a few tokens per message for roles and separators, and tool or system prompts count too. Add some headroom.