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, four provider views

This token calculator measures text prompts, code, structured data, readable documents, and supported images against current OpenAI, Anthropic Claude, Google Gemini, and DeepSeek models.

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.

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-08-23

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

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.