AI Token Calculator

Paste text or upload a file to count tokens, characters, words and lines. Everything runs locally in your browser — your content is never uploaded.

Never miss an AI pricing or launch update

Get notified about pricing changes, provider updates, new model launches, and cost-saving insights.

🔒 We respect your privacy. Unsubscribe anytime.

Drag & drop a text, code or image file here, or use “Upload file”. Text & code (.txt, .md, .csv, .json, .yaml, .xml, .html, .js, .ts, .py, .php, .sql, …) are counted as text; images (.png, .jpg, .webp, .gif) are measured as vision tokens. Max 10 MB.

Private by design. Your text, files and images are processed entirely in your browser. Nothing is sent to our servers, stored, or logged. Reset with “Clear” to wipe everything from memory.

Counts

Tokens
0
Characters
0
Characters (no spaces)
0
Words
0
Lines
0
Sentences
0

Token counts use OpenAI's BPE tokenizers where available; otherwise a character-based estimate (shown with “≈”). Image files are measured as high-detail vision tokens. Other providers tokenize differently, so treat non-OpenAI models as approximate.

Token visualization

Pieces appear as the local tokenizer reads your text.

0 tokens

Paste or type text above to see how it is split into tokens.

Price Comparison

Estimated input cost for your current 0 tokens, sorted from highest to lowest.

Highest
Lowest
$0Max —

Add some text above to estimate cost across models.

Full model pricing table

Rates update the estimates as soon as you paste text.
Model Provider Context Current rate / 1M tokens Estimated cost Pricing tier
Claude Opus 4.5 Perplexity 200K
Input
$5
Cached
$0.5
Output
$25
Input
Cached
Output
Standard
Claude Opus 4.5 Anthropic 200K
Input
$5
Cached
$0.5
Output
$25
Input
Cached
Output
Standard
Claude Opus 4.6 Anthropic 200K
Input
$5
Cached
$0.5
Output
$25
Input
Cached
Output
Standard
Claude Opus 4.6 Perplexity 200K
Input
$5
Cached
$0.5
Output
$25
Input
Cached
Output
Standard
Claude Opus 4.7 Anthropic 200K / 32K
Input
$5
Cached
$0.5
Output
$25
Input
Cached
Output
Standard
Claude Opus 4.7 Perplexity 200K / 32K
Input
$5
Cached
$0.5
Output
$25
Input
Cached
Output
Standard
Claude Sonnet 4.5 Anthropic 200K
Input
$3
Cached
$0.3
Output
$15
Input
Cached
Output
Standard
Claude Sonnet 4.5 Perplexity 200K
Input
$3
Cached
$0.3
Output
$15
Input
Cached
Output
Standard
Claude Sonnet 4.6 Anthropic 200K
Input
$3
Cached
$0.3
Output
$15
Input
Cached
Output
Standard
Claude Sonnet 4.6 Perplexity 200K
Input
$3
Cached
$0.3
Output
$15
Input
Cached
Output
Standard
gpt-5.5 OpenAI 1,050K / 128K
Input
$5
Cached
$0.5
Output
$30
Input
Cached
Output
Standard

Long context after 272K input: input $10, cached $1, output $45.

gpt-5.5-pro OpenAI 1,050K / 128K
Input
$30
Cached
Not offered
Output
$180
Input
Cached
Output
Standard

Long context after 272K input: input $60, output $270.

gpt-5.6-luna OpenAI 1,050K / 128K
Input
$1
Cached
$0.1
Output
$6
Input
Cached
Output
Standard

Long context after 272K input: input $2, cached $0.2, output $9.

gpt-5.6-sol OpenAI 1,050K / 128K
Input
$5
Cached
$0.5
Output
$30
Input
Cached
Output
Standard

Long context after 272K input: input $10, cached $1, output $45.

gpt-5.6-terra OpenAI 1,050K / 128K
Input
$2.5
Cached
$0.25
Output
$15
Input
Cached
Output
Standard

Long context after 272K input: input $5, cached $0.5, output $22.5.

What the AI Token Calculator does

The AI Token Calculator is a free, privacy-first tool that tells you exactly how many tokens a piece of text, a source file or an image will consume when sent to a large language model (LLM). Tokens are the currency of modern AI: every request to GPT-4o, GPT-4, Claude, Gemini, Llama or any other model is measured, billed and capped in tokens rather than words. If you have ever been surprised by an API invoice, hit a mysterious “context length exceeded” error, or tried to squeeze a long document into a prompt, this calculator gives you the precise numbers you need before you spend a cent. Alongside the token total it also reports characters, characters without spaces, words, lines and sentences, so you get a complete picture of your content in one place.

How to use it

Getting a count takes just a few seconds:

  1. Add your content. Paste or type directly into the text box, click Upload file to pick a document, or simply drag and drop a file or image anywhere onto the input box.
  2. Choose a tokenizer that matches the model you are targeting — for example o200k_base for GPT-4o and the o-series, or cl100k_base for GPT-4 and GPT-3.5.
  3. Read your results instantly. The token count and every other metric update live as you type or as soon as a file finishes loading — there is no “calculate” button to press.
  4. Press Clear when you are done to wipe the content from memory. Nothing persists between sessions and nothing is ever saved.

Because everything runs locally, you can safely paste confidential prompts, proprietary code, contracts or customer data without it ever leaving your machine.

How it works

Language models do not read raw characters — they read tokens produced by a tokenizer. Most modern models use a technique called byte-pair encoding (BPE), which starts from individual bytes and repeatedly merges the most frequent adjacent pairs into larger units. The result is a vocabulary in which common words become a single token, rarer words split into several sub-word pieces, and spaces and punctuation are represented explicitly. This is why “dog” might be one token while “antidisestablishmentarianism” becomes many, and why the same word can tokenize differently depending on whether it is preceded by a space.

This calculator loads OpenAI’s actual open-source tokenizers in your browser and runs them over your text, so the count for OpenAI models is exact rather than estimated. When you pick the generic option, or if the tokenizer library cannot be loaded, it falls back to the well-known heuristic of roughly four characters per token and marks the figure with a “≈” to show it is an approximation. All of this happens client-side in JavaScript; your data never touches a server, which is what makes the tool both fast and private.

The tokenizer options explained

  • o200k_base — the newest OpenAI tokenizer, used by GPT-4o, GPT-4o mini, GPT-4.1 and the o1 / o3 reasoning models. It has a ~200k-token vocabulary and is more efficient on code and non-English text, so the same passage often uses fewer tokens than with older encoders.
  • cl100k_base — the tokenizer behind GPT-4, GPT-4 Turbo, GPT-3.5 Turbo and the text-embedding-3 models. Choose this whenever you are budgeting for those specific models.
  • Generic estimate (~4 chars/token) — a fast, model-agnostic approximation for providers whose tokenizers are not bundled here, such as Anthropic Claude, Google Gemini or Meta Llama. Treat it as a close ballpark; real counts on those platforms will be within a small margin.

Supported file types

You can drag in or upload files up to 10 MB. There are two categories:

Text & code (counted as text tokens):

.txt, .text, .md, .markdown, .mdx, .rst, .csv, .tsv, .json, .jsonl, .ndjson, .yaml, .yml, .toml, .ini, .env, .xml, .html, .htm, .css, .scss, .js, .mjs, .cjs, .jsx, .ts, .tsx, .py, .rb, .php, .java, .kt, .c, .h, .cpp, .cc, .cs, .go, .rs, .swift, .sh, .bash, .zsh, .sql, .log, .tex, .srt, .vtt — and most other UTF-8 text formats.

Images (measured as vision tokens):

.png, .jpg, .jpeg, .webp, .gif, .bmp

Binary formats such as PDF, DOCX, XLSX or ZIP are not decoded here because their tokenization depends on how a given model extracts text from them; export or copy the underlying text first for an accurate count.

How image (vision) tokens are counted

Multimodal models like GPT-4o charge for images in tokens too. When you drop in a PNG, JPG, WebP or GIF, the calculator reads the image’s pixel dimensions locally and applies OpenAI’s high-detail tiling formula: the image is first scaled to fit inside a 2048×2048 box, then its shortest side is scaled to 768 pixels, and the result is divided into 512-pixel tiles. Each tile costs 170 tokens on top of an 85-token base, so a small image might be a few hundred tokens while a large, detailed one can be well over a thousand. Low-detail mode, by contrast, is a flat 85 tokens regardless of size. The image itself is never uploaded — only its width and height are used.

How it helps you

  • Estimate cost before you call the API. Multiply your input and expected output tokens by a model’s per-token price — you can compare those prices across providers on our models directory — to forecast spend accurately.
  • Stay inside the context window. Every model has a maximum number of tokens it can handle in one request. Counting first prevents truncated prompts and “context length exceeded” errors.
  • Optimise prompts and RAG chunks. See instantly how trimming instructions, compressing examples or resizing retrieved passages changes your token footprint.
  • Budget fine-tuning and embeddings. Training files and embedding jobs are billed per token, so a quick count keeps large datasets predictable.
  • Protect sensitive data. Because the tool is fully client-side, you can measure private or regulated content without any compliance risk.

Tokens vs. words vs. characters

A common rule of thumb for English is that one token is about four characters or roughly 0.75 words, so 1,000 tokens is around 750 words and a single page of prose is often 500–650 tokens. These ratios shift with language, formatting and code: dense punctuation, emoji, non-Latin scripts and long identifiers all push the token count up relative to the word count. That is exactly why an exact tokenizer beats guessing — and why this page shows characters, words and tokens side by side so you can see the relationship for your own content.

Frequently asked questions

What is a token in AI models?

A token is the basic unit a language model reads and generates. Tokens are chunks of text produced by a tokenizer — often a whole short word, a word fragment, a space, or a punctuation mark. As a rough guide, one English token is about four characters or roughly three-quarters of a word, so 1,000 tokens is around 750 words. Models bill you and enforce context limits in tokens, not words, which is why counting them accurately matters.

How accurate is this token counter?

For OpenAI models the count is exact: we run the same byte-pair-encoding (BPE) tokenizers OpenAI uses — o200k_base for GPT-4o, GPT-4.1 and the o-series, and cl100k_base for GPT-4, GPT-3.5 Turbo and the v3 embeddings. For other providers such as Anthropic, Google or Meta, tokenization differs slightly, so use the generic estimate as a close approximation.

Is my text or file uploaded anywhere?

No. All counting happens entirely inside your browser using JavaScript. Your pasted text, uploaded documents and images are never transmitted to our servers, never logged, and never stored. Closing the tab or pressing Clear removes everything from memory.

Which file types are supported?

Plain-text and code files (.txt, .md, .csv, .json, .yaml, .xml, .html, .js, .ts, .py, .java, .go, .rb, .php, .sql, .log and many more) are counted as text. Image files (.png, .jpg, .jpeg, .webp, .gif) are measured as vision tokens using the image-tiling formula that GPT-4o-class models use.

How are image (vision) tokens calculated?

For images we estimate high-detail vision tokens the way OpenAI GPT-4o does: the image is scaled to fit within 2048×2048, then its shortest side is scaled to 768 pixels, and the result is divided into 512-pixel tiles. Each tile costs 170 tokens plus an 85-token base. Low-detail mode is a flat 85 tokens regardless of size.