Privacy-first · browser-based token calculator

Count tokens in text, files, and images.

Paste a prompt or attach PDF, DOCX, code, data files, and images. Provider results and costs update live without uploading your content.

Everything stays in this browserLive

Text, code, PDF, DOCX, PNG, JPEG, WebP, or GIF · 12 MB per file

How it works

A measurement, not a guess disguised as fact.

OpenAI text uses exact local o200k_base BPE tokenization. Claude, Gemini, and DeepSeek use deterministic Provider-Calibrated UTF-8 Token Projections. Supported images follow each provider’s published visual-token formulas, including patch, tile, detail, and model-cap rules.

Every result identifies its method and accuracy level. Pricing is refreshed from Models.dev with the bundled registry available as an offline fallback.

Read the complete methodology →
What it measures

One input, every major provider

This token calculator measures text prompts, code, structured data, readable documents, and supported images against 35 current models from 9 providers: OpenAI, Anthropic, Google, DeepSeek, Qwen, Moonshot Kimi, xAI Grok, Z.ai GLM, Meta.

It reports input tokens, context-window fit, and estimated input cost. Text and files stay in the browser; only public model metadata may be refreshed from Models.dev.

LLM API pricing

Token prices for every supported model

Rates verified 2026-09-09

Cost per 1,000,000 tokens in USD, for input and output separately. Cached input is the discounted rate providers charge when a prompt prefix is reused. Paste a real prompt into the calculator above to turn these rates into a cost for your own workload.

ModelProviderContext windowInput / 1MCached input / 1MOutput / 1M
GPT-6 AstraOpenAI1,050,000$10$1$50
GPT-5.6 LunaOpenAI1,050,000$0.2$0.02$1.2
GPT-5.6 SolOpenAI1,050,000$4$0.4$20
GPT-5.6 TerraOpenAI1,050,000$2$0.2$12
Claude Fable 5.1Anthropic1,000,000$10$0.25$50
Claude Opus 5Anthropic1,000,000$5$0.5$25
Claude Sonnet 5Anthropic1,000,000$2$0.2$10
Claude Opus 4.8Anthropic1,000,000$5$0.5$25
Claude Haiku 4.5Anthropic200,000$1$0.1$5
Gemini 3.8 FlashGoogle1,048,576$0.75$0.075$3.75
Gemini 3.7 FlashGoogle1,048,576$0.75$0.075$3.75
Gemini 3.5 Flash LiteGoogle1,048,576$0.3$0.03$2.5
Gemini 3.1 Flash LiteGoogle1,048,576$0.25$0.025$1.5
Gemini 2.5 ProGoogle1,048,576$1.25$0.125$10
DeepSeek V4 ProDeepSeek1,000,000$0.435$0.003625$0.87
DeepSeek V4 FlashDeepSeek1,000,000$0.14$0.0028$0.28
Qwen3.8 FlashQwen1,000,000$0.15$0.016$0.47
Qwen3.8 MaxQwen1,000,000$2$0.25$6
Qwen3.7 PlusQwen1,000,000$0.5$0.05$3
Qwen3.7 MaxQwen1,000,000$2.5$0.5$7.5
Qwen3.6 FlashQwen1,000,000$0.1875$1.125
Kimi K3Moonshot Kimi1,048,576$3$0.3$15
Kimi K2.7 CodeMoonshot Kimi262,144$0.95$0.19$4
Kimi K2.6Moonshot Kimi262,144$0.95$0.16$4
Grok 4.6xAI Grok500,000$2$0.5$6
Grok 4.5xAI Grok500,000$2$0.3$6
Grok 4.3xAI Grok1,000,000$1.25$0.2$2.5
GLM-5.3-FlashZ.ai GLM1,000,000$0.075$0.015$0.25
GLM-5.3Z.ai GLM1,000,000$1.4$0.26$4.4
GLM-5.2Z.ai GLM1,000,000$1.4$0.26$4.4
GLM-5.1Z.ai GLM200,000$1.4$0.26$4.4
GLM-5-TurboZ.ai GLM200,000$1.2$0.24$4
Muse Spark 1.3Meta1,048,576$1.25$0.15$4.25
Muse Spark 1.2Meta1,048,576$1.25$0.15$4.25
Muse Spark 1.1Meta1,048,576$1.25$0.15$4.25

Rates come from the public model catalogue and refresh from the same live source the calculator uses. Long-context tiers, batch discounts, and provider-side overheads can change a real invoice. Provider documentation remains authoritative.

Calculation pipeline

From input payload to token projection

Computation provenance remains visible, distinguishing exact BPE tokenization from deterministic provider-calibrated projection.

  1. InputText · file · imageRead locally
  2. MethodTokenize or estimateMethod stays visible
  3. LimitCheck context fitWarn before overflow
  4. ResultCalculate input costApply current rates
Token calculation processText, documents, and images pass through a provider counting method, then context and cost calculations.INPUTText · file · imageRead locallyMETHODTokenizeor estimateLIMITContext fitwith overflow alertRESULTInput costat current rates
Input cost = input tokens ÷ 1,000,000 × model input price.
Document token counter

Calculate tokens from a PDF, Word file, codebase excerpt, or data file

Upload a text-based PDF or DOCX document instead of copying its contents page by page. TokenCalculator.dev extracts readable text inside the browser, combines it with anything in the prompt editor, and immediately recalculates every provider result.

Plain text, Markdown, CSV, JSON, JavaScript, TypeScript, Python, Go, Rust, Java, C/C++, HTML, CSS, XML, YAML, TOML, SQL, and shell files are also supported up to 12 MB per file. Scanned PDFs need OCR and are intentionally rejected rather than returning a misleading zero-token result.

Privacy: document contents never leave the device. No prompt or uploaded file is sent to a token-counting server.

Image token calculator

Estimate image tokens before sending a vision request

Add a PNG, JPEG, WebP, or GIF to compare its visual-token footprint across supported OpenAI, Claude, and Gemini models. The calculator reads width and height locally and applies the selected provider’s documented tile, patch, or media-token rule.

Image tokens are added to extracted document text and pasted prompt text, so a multimodal request can be planned as one workload. If a selected model has no documented vision rule, the result says image unavailable instead of presenting a fabricated estimate.

This is an image-token and cost estimate, not OCR. Pixel data is not uploaded, retained, or used to extract words from an image.

Workload field notes

See what you can measure before the API call

Representative planning workflows now; attributable developer reviews are added only after their wording and permission are verified.

COMMUNITY WORKFLOW LOG

Be one of the first featured developers

Tell us what you measured, which providers you compared, and what decision the result helped you make. Published reviews include attribution and require explicit permission.

Share your workflow
Accuracy contract

Exact where possible. Labeled where estimated.

Registry reviewed 2026-09-09

ProviderText methodImage methodResult label
OpenAILocal model BPEPublished tile rulesExact BPE / provider formula
ClaudeProvider-Calibrated UTF-8 ProjectionPublished patch rulesDeterministic projection
GeminiProvider-Calibrated UTF-8 ProjectionPublished media rulesDeterministic projection
DeepSeekProvider-Calibrated UTF-8 ProjectionUnavailable when undocumentedDeterministic projection
Useful definitions

The numbers behind an LLM request

Token
A small unit of text processed by a language model. A token may be a word, part of a word, punctuation, or whitespace.
Input token
Content sent to the model, including prompts, context, instructions, and API message structure.
Output token
Content generated by the model. Providers normally price output separately from input.
Cached token
Previously processed prompt content eligible for a reduced provider rate when caching rules are satisfied.
Context window
The maximum combined input and output capacity available to a model for one request.
Price per million
The standard API rate multiplied by token usage. Actual billing may include tiers, caching, tools, or provider-side tokens.
Focused counters

Measure against the model you use

Current model comparisons

Compare cost with the same real workload

Cost guides

Compare approaches, not just models

Plain answers

Frequently asked questions

Can I calculate tokens from files and images?+

Yes. Attach PDF, DOCX, code, data, PNG, JPEG, WebP, or GIF files. Text extraction, image-dimension reading, and token measurement run locally in your browser.

Does this tool upload my content?+

No. Your text, documents, code, and images stay in your browser and are not sent to TokenCalculator.dev or another calculation server.

What is a token in an AI model?+

A token is a small unit of content processed by a language model. It may be a whole word, part of a word, punctuation, whitespace, or—in multimodal models—a unit assigned to an image. Different providers can split the same input differently.

How is LLM API input cost calculated?+

Input cost is calculated as input tokens divided by one million, multiplied by the selected model’s input price per million tokens. Provider tiers, cached input, tools, and message wrappers can affect final billing.

Does this tool upload my prompt, document, or image?+

No. Text, PDF and DOCX extraction, image-dimension reading, and token calculations run in your browser. Zero prompts, document contents, or uploaded images are sent to TokenCalculator.dev or another calculation server.

Are the token counts exact?+

OpenAI text counts use the matching local BPE encoding. Other providers are clearly labeled estimates unless they publish a deterministic local formula. Image counts use provider-published rules.

How do I count tokens in a PDF or Word document?+

Attach a text-based PDF or DOCX file and the browser extracts its readable text locally, then counts it with every selected provider model. Scanned or encrypted PDFs require OCR and are not supported.

Can I calculate image tokens and vision-model cost?+

Yes. Add a PNG, JPEG, WebP, or GIF. For supported vision models, the calculator reads its pixel dimensions locally and applies the provider-published image token formula. It reports unavailable instead of inventing a value when a provider has no documented rule.

Why can the API report a slightly different count?+

Providers can add message wrappers, system instructions, tools, or model-specific processing. The accuracy badge and methodology explain what this calculator includes.