Skip to content
I Hate Online Tools

Token counter

Estimate how many tokens a prompt uses for common LLM tokenizers.

Runs in this tab. The file stays here.

Tokens
…
Words
0
Characters
0
Est. words from tokens
…

Exact for OpenAI models using this encoding. Claude, Gemini, and Llama use different tokenizers, so treat their counts as close estimates (usually within 10–20%).

This runs in your browser. Nothing is uploaded.

About Token counter

Count the tokens in a prompt with the GPT-4 or GPT-4o tokenizer, plus words and characters. The text is counted in this tab and never sent to an API.

Model limits and prices are measured in tokens, not words. In plain English prose a token is about four characters, or three-quarters of a word, but code, numbers, emoji, and anything that isn't English use noticeably more. Paste your text and the page shows tokens, words, characters, and a words-from-tokens figure, which is just the token count times 0.75.

There are two tokenizers to choose from: cl100k_base, used by GPT-4 and GPT-3.5, and o200k_base, used by GPT-4o and newer OpenAI models. For those models the count is exact. Claude, Gemini, and Llama each tokenize differently, and their tokenizers aren't bundled here, so for them treat the number as a close estimate, usually within 10 to 20 percent. If you're anywhere near a hard limit on one of those models, leave a margin or check with the provider's own counter.

The tokenizer is a JavaScript library that loads with the page and runs in your browser, so a customer document or an unreleased system prompt isn't posted to a counting service. It treats text that looks like a special token (the angle-bracket markers some models use for control) as ordinary characters. It counts one blob of text at a time and does not count the extra tokens a chat API adds around each message.

How to use Token counter

  1. 1Paste your prompt or text.
  2. 2Pick cl100k_base or o200k_base, whichever matches your model family.
  3. 3Read the token, word, and character counts.

What it won't do

  • Exact only for the two OpenAI encodings offered; other vendors are estimates.
  • Counts raw text, not chat-message or tool-schema overhead.
  • No image or file token counting.

Common questions

Is the count exact?

For OpenAI models that use the selected encoding, yes. For Claude, Gemini, Llama and others it's an estimate, because those families use different tokenizers that this page doesn't include. Expect a gap of 10 to 20 percent and leave headroom under any limit.

Which tokenizer should I pick?

o200k_base for GPT-4o and newer OpenAI models, cl100k_base for GPT-4 and GPT-3.5. If you're counting for a different vendor, either gives a reasonable ballpark; o200k_base is the more recent of the two.

Does the count include chat message overhead?

No. It tokenizes the text you paste, as one string. Chat APIs add a few tokens per message for roles and separators, and tool definitions add more, so a real request will be somewhat higher than this number.

Does my text get sent to an AI provider?

No. Counting is done by bundled code in this tab. Nothing is transmitted, and you can turn off the network after the page loads and it still works.

Related tools

Why this one doesn't upload your file

There is no server to upload to. This page is a static file, and the work happens in your browser using the same graphics and WebAssembly code that renders every other site you visit. Your file is read from disk into memory, processed, and handed back as a download. Once the page has loaded you can disconnect from the network entirely and it keeps working. The longer explanation

Install the app