Tools

AI Token Calculator

Paste any prompt or document to count tokens and instantly estimate input, cached and output costs across every major model — GPT, Claude, Gemini, Grok, DeepSeek, Qwen, GLM, MiniMax and Mistral. Pricing is a June 2026 snapshot from official provider docs.

Estimating… loading exact tokenizer
150characters
23words
38input tokens
8output tokens
≈ 21% of input
output tokens
Cost by provider
OpenAIexact
Input · 38 tok
$0.00019
Output · 8 tok
$0.00024
Est. total
$0.00043

1M ctx · flagship

Anthropic≈ est.
Input · 44 tok
$0.00022
Cached input
$0.000022
Output · 9 tok
$0.00022
Est. total
$0.00044

1M ctx · new flagship

Google Gemini≈ est.
Input · 40 tok
$0.000060
Cached input
$0.000015
Output · 8 tok
$0.000060
Est. total
$0.00012

1M ctx · replaces 3.5 Flash

Meta≈ est.
Input · 38 tok
$0.000048
Cached input
$0.0000057
Output · 8 tok
$0.000034
Est. total
$0.000082

1M ctx · coding-focused

xAI Grok≈ est.
Input · 38 tok
$0.000076
Cached input
$0.000019
Output · 8 tok
$0.000048
Est. total
$0.00012

500K ctx; ≥200K prompt doubles rates

DeepSeek≈ est.
Input · 40 tok
$0.000070
Cached input
$5.8e-7
Output · 8 tok
$0.000028
Est. total
$0.000097

MIT · 1M ctx

Alibaba Qwen≈ est.
Input · 38 tok
$0.000076
Output · 8 tok
$0.000048
Est. total
$0.00012

1M ctx · open weight planned

Z.ai GLM≈ est.
Input · 38 tok
$0.000053
Output · 8 tok
$0.000035
Est. total
$0.000088

1M ctx · open

Moonshot AI≈ est.
Input · 38 tok
$0.00011
Cached input
$0.000011
Output · 8 tok
$0.00012
Est. total
$0.00023

1M ctx · open weight

Thinking Machines≈ est.
Input · 38 tok
$0.000071
Cached input
$0.000014
Output · 8 tok
$0.000037
Est. total
$0.00011

64K ctx · Apache 2.0

MiniMax≈ est.
Input · 38 tok
$0.000011
Output · 8 tok
$0.0000096
Est. total
$0.000021

1M ctx · open

Mistral≈ est.
Input · 42 tok
$0.000021
Output · 9 tok
$0.000013
Est. total
$0.000034

Apache-2.0 · 256K ctx

Perplexity≈ est.
Input · 38 tok
$0.000076
Output · 8 tok
$0.000064
Est. total
$0.00014

+ reasoning tokens billed

Prices are USD per 1M tokens, June 2026 snapshot. Only the OpenAI family is tokenized exactly (o200k); other counts are estimates (±15% typical for English; non-Latin scripts vary more). * = output price varies by source. Verify on the provider’s pricing page before relying on it.

What you can do with this calculator

Every model charges per token, so knowing your token count up front is the only way to predict cost before you call an API. This tool counts the input tokens in your text, estimates a realistic output length, and computes the cost for each provider so you can compare models side by side and pick the right price-performance fit.

  • Exact GPT tokenization. The OpenAI family is counted with the real o200k tokenizer; other models use calibrated estimates (English text is typically within ±15%).
  • Output presets. Switch between RAG / Q&A, Chat, Full response and Long generation, or override the output token count directly.
  • Cached input pricing. Where providers publish a cache-read rate, it’s shown so you can model prompt-caching savings.
  • Sort & copy. Rank providers cheapest-first and copy any estimate to share.

Current API prices (June 2026)

All prices are USD per 1M tokens, from official provider pricing pages.

ProviderModelInputCached inOutput
OpenAIGPT-5.5$5.00$0.50$30.00
OpenAIGPT-5.5 Pro$30.00$180.00
AnthropicClaude Opus 4.8$5.00$0.50$25.00
AnthropicClaude Fable 5$10.00$1.00$50.00
GoogleGemini 3.5 Flash$1.50$0.15$9.00
GoogleGemini 3.1 Pro$2.00$0.20$12.00*
xAIGrok 4.3$1.25$0.20$2.50
DeepSeekV4-Pro$1.74$0.0145$3.48
DeepSeekV4-Flash$0.14$0.0028$0.28
AlibabaQwen3.7-Max$2.50$0.25$7.50
Z.aiGLM-5.2$1.40$4.40
MiniMaxM3$0.30$1.20
MistralLarge 3$0.50$1.50
* Gemini 3.1 Pro output pricing varies by source ($4–12); we use $12 as a conservative default.

Programming language token efficiency, ranked

The same task costs wildly different token counts depending on the language. Terse functional and dynamic languages stay compact; verbose low-level and enterprise languages burn more tokens for identical work. Averages below use a RosettaCode task with GPT-family tokenization as the baseline.

LanguageAvg tokensTypesVerdict for LLM agents
J~70DynamicUltra-compact, niche tradeoff
Clojure~109DynamicBest for long agent sessions
Ruby~119DynamicVery token-efficient
Python~128DynamicStrong balance of cost & readability
Haskell~130StaticLean despite static typing
F#~136StaticEfficient typed option
Lisp~145DynamicCompact, less mainstream
Scala~166StaticAcceptable overhead
JavaScript~177DynamicUsable, not especially lean
Go~182StaticModerate token cost
C#~216StaticNoticeable token tax
Java~224StaticHigh token tax
C++~250StaticExpensive in long contexts
C~283StaticWorst for token efficiency
Methodology adapted from the RosettaCode token comparison published by tokencalculator.ai.

FAQ

What is a token?

Tokens are the chunks of text models read and write. One token is roughly four characters of English (about ¾ of a word) — so “ChatGPT” is about two tokens. Different models tokenize slightly differently, which is why counts vary per provider.

How accurate are the token counts?

The OpenAI family is exact (we run the real o200k tokenizer in your browser). Other providers don’t publish official JavaScript tokenizers, so those counts are calibrated estimates — usually within ±15% for English, with more variance for code and non-Latin scripts.

Why estimate output tokens?

Output tokens are usually the larger cost (often 3–6× the input rate), but you don’t know the exact length until the model responds. The presets give a realistic range by task type so your estimate is closer to the real bill.

What is cached input?

Many providers cache repeated prompt prefixes and bill cache reads at a steep discount (often ~10% of the input rate, and far less for DeepSeek). If you reuse a long system prompt, cached pricing can cut input cost dramatically.


Pricing snapshot: June 2026, compiled from official provider docs and our 2026 LLM landscape. Verify on the provider’s pricing page before relying on it. Runs entirely in your browser — no text is sent anywhere.