Skip to content

OpenAI Token Calculator

Count tokens for OpenAI models exactly, in your browser. This calculator counts with the same o200k_base encoding OpenAI's current models use (via gpt-tokenizer), so supported OpenAI counts are labeled Exact — then it estimates API cost and checks context-window fit.

Private by default · No signup · Local token counting where supported · Exact and estimated results clearly labeled

Your text is processed in your browser for supported local tokenizers. We do not store pasted prompts.

Import .txt, .md, or .json files locally. Files are read in your browser and are not uploaded to our server.

Model comparison

Compare the current prompt, expected output, and monthly call volume across supported OpenAI models.

Same-prompt model comparison table with token count accuracy, cost, and context fit.
ModelAccuracyPrompt tokensPer-call costMonthly costContext fit
OpenAI · GPT-5.5gpt-5.5Exact
OpenAI · GPT-5.4gpt-5.4Exact
OpenAI · GPT-5.4 minigpt-5.4-miniExact
OpenAI · GPT-5.4 nanogpt-5.4-nanoExact
Anthropic · Claude Fable 5claude-fable-5Estimated
Anthropic · Claude Opus 4.8claude-opus-4-8Estimated
Anthropic · Claude Sonnet 5claude-sonnet-5Estimated
Anthropic · Claude Sonnet 4.6claude-sonnet-4-6Estimated
Anthropic · Claude Opus 4.6claude-opus-4-6Estimated
Anthropic · Claude Haiku 4.5claude-haiku-4-5-20251001Estimated
Google · Gemini 3.5 Flashgemini-3.5-flashEstimated
Google · Gemini 3.1 Pro Previewgemini-3.1-pro-previewEstimated
Google · Gemini 3.1 Flash-Litegemini-3.1-flash-liteEstimated
Google · Gemini 3 Flash Previewgemini-3-flash-previewEstimated
Google · Gemini 2.5 Progemini-2.5-proEstimated
Google · Gemini 2.5 Flashgemini-2.5-flashEstimated
Google · Gemini 2.5 Flash-Litegemini-2.5-flash-liteEstimated
Mistral · Mistral Largemistral-large-latestEstimated
Mistral · Mistral Mediummistral-medium-latestEstimated
Mistral · Mistral Smallmistral-small-latestEstimated
Mistral · Ministral 14Bministral-14b-latestEstimated
DeepSeek · DeepSeek V4 Flashdeepseek-v4-flashEstimated
DeepSeek · DeepSeek V4 Prodeepseek-v4-proEstimated
xAI · Grok 4.3grok-4.3Estimated
xAI · Grok Build 0.1grok-build-0.1Estimated
Meta · Llama 4 Scoutmeta-llama/Llama-4-Scout-17B-16E-InstructEstimated
Meta · Llama 4 Maverickmeta-llama/Llama-4-Maverick-17B-128E-InstructEstimated

Estimated rows use one local OpenAI-compatible proxy token count, so real provider counts can differ. Pricing estimate based on public model pricing. Check provider pricing before production use.

Why OpenAI token counts are Exact

gpt-tokenizer is a faithful port of OpenAI's own tokenizer. When the calculator counts an OpenAI model with its correct encoding, the result matches OpenAI's count, so the tool labels it Exact instead of Estimated. Providers without a local tokenizer stay clearly labeled Estimated.

o200k_base

The encoding used by OpenAI's current generation, including the GPT-5 family and GPT-4o. Every OpenAI model in this tool counts with o200k_base, so its token counts are Exact.

cl100k_base

The encoding used by earlier models such as GPT-4, GPT-3.5 Turbo, and the text-embedding-3 models. gpt-tokenizer supports it too, so those models can be added later without a new engine.

A note on chat messages

This tool counts the raw text you paste. OpenAI's Chat Completions API adds a few tokens per message for role and formatting, so a full multi-message request runs slightly higher than the raw text count. Paste your combined prompt to plan input tokens and cost.

OpenAI token calculator FAQ

Answers about Exact OpenAI counting, encodings, and cost planning.

Is this calculator exact?

It is Exact only for supported OpenAI encodings counted locally with gpt-tokenizer. Other providers are labeled Estimated and use an OpenAI-compatible tokenizer as a proxy, so real provider counts can vary.

What is an LLM token?

A token is a chunk of text a language model reads or writes. A token can be a whole word, part of a word, punctuation, whitespace, a number, or part of code.

Why do different models show different token counts?

Different model families use different tokenizers. The same prompt can split into different token pieces for OpenAI, Claude, Gemini, Llama, Mistral, DeepSeek, or Grok models.

Can I count tokens for code or JSON?

Yes. You can paste code, JSON, Markdown, prose, or mixed documents. The calculator also shows word and character counts so you can compare text shape alongside tokens.

What are input vs output tokens, and why is output usually more expensive?

Input tokens are the prompt and context you send to the model. Output tokens are the model's response. Providers often price output tokens higher because generating text costs more compute than reading input.

Can I estimate monthly API cost?

Yes. Enter expected output tokens and calls per month. The calculator combines those values with the selected model's public pricing to estimate per-call and monthly cost.

Is my prompt uploaded to your server?

No. Pasted text is processed in your browser. This site has no accounts, saved prompt history, analytics scripts, ad scripts, or server-side text processing.

More token tools

Need every provider at once? The main LLM token calculator prices the same prompt across OpenAI, Claude, Gemini, Llama, Mistral, DeepSeek, Grok, and more.