Token Counter & LLM Cost Calculator

Count tokens exactly with OpenAI’s tokenizer, plan a context-window budget, compare API costs across Claude, OpenAI and Gemini, preview RAG chunks and price images. Everything runs in your browser.

No data leaves your browser
Text
Characters
0
Words
0
Lines
0
Tokens
0
OpenAI counts use the real tiktoken vocabulary (about 2 MB, downloaded once from this site and cached). Anthropic and Google don’t publish their tokenizers, so Claude and Gemini figures are character-ratio estimates. Claude 4.7 and later use a newer tokenizer that produces roughly 30% more tokens than earlier Claude models. For exact Claude counts, use the API’s count_tokens endpoint.
What goes into each request
Used
0
Remaining
0
Turns until full
–
at the per-turn growth below
Tip: count a block of text on the Count tab, then paste the number here. Context windows and output limits come from each provider’s documentation; pick “Custom” for anything not listed.
ModelInput $/MCached $/MOutput $/MPer requestPer dayPer month
Document
Drop images here or click to choose. Images are measured locally and never uploaded.
Claude: one token per 28×28 px patch after downscaling to fit the model’s long-edge and token limits (Anthropic vision docs). OpenAI tile models: scale to fit 2048×2048, shortest side to 768 px, then base + per-512 px tile tokens (detail: high). OpenAI patch models: ⌈w/32⌉×⌈h/32⌉×1.2. Model-specific patch budgets are not applied, so treat this row as an upper-bound estimate.

How to use the Token Counter

  1. Paste your prompt or document and pick a tokenizer.
  2. See the exact OpenAI token count (or a Claude/Gemini estimate).
  3. Use Context Budget to check it fits the model, and Cost to compare providers.
  4. Use Chunking to preview RAG chunks, and Image Tokens for vision inputs.

Why use this Token Counter

  • Exact tiktoken counts (o200k_base, cl100k_base)
  • Context-window planner for Claude, GPT and Gemini
  • API cost comparison with caching and Batch discounts
  • RAG chunk visualizer and image token calculator

Frequently Asked Questions

Is this token counter exact?

For OpenAI models it is: picking o200k_base or cl100k_base runs the real tiktoken vocabulary (via js-tiktoken) in your browser. Anthropic and Google do not publish their tokenizers, so Claude and Gemini counts are clearly labelled estimates.

Is my text uploaded anywhere?

No. Tokenizing, chunking and cost maths all run locally. The tokenizer files are served from this site and cached by your browser.

Which models use o200k_base?

OpenAI's GPT-4o, GPT-4.1, the o-series and the GPT-5 family use o200k_base. GPT-4 and GPT-3.5 Turbo use cl100k_base.

How is the API cost calculated?

Cost = uncached input × input price + cached input × cache-read price + output × output price, per request, multiplied by your daily volume. Batch halves both input and output. Cache-write surcharges and long-context tiers are not included.

How do I choose a chunk size and overlap for RAG?

Start with 500–1,000 tokens and 10–20% overlap, then check the Chunking tab to see whether chunks break mid-sentence or split related sections. Recursive or Markdown-aware splitting usually keeps ideas together better than fixed windows.

How many tokens does an image cost?

Claude counts one token per 28×28-pixel patch after downscaling to the model's limit (2576 px / 4784 tokens on Claude 4.7 and later, 1568 px / 1568 tokens on older models). OpenAI tile models charge a base amount plus a fee per 512 px tile. The Image Tokens tab applies these rules.

What is a token?

A token is a chunk of text a language model processes: often a whole word, part of a word or a punctuation mark. Models are priced and limited by token count, not characters.

More Developer Tools

JSON ToolsFormat, validate, minify & compare JSON JSON FormatterPretty-print and beautify JSON CSV Viewer & EditorView, edit and convert CSV files YAML ConverterConvert YAML to JSON and back Regex TesterTest regular expressions live Text DiffCompare two texts side by side JWT ToolDecode, encode, compare and verify JWTs JWT DecoderInspect JWT header and payload XML FormatterFormat, validate and convert XML URL EncoderEncode, decode and parse URLs Base64Encode and decode Base64 strings Hash GeneratorSHA-256, MD5, HMAC and CRC32 SHA-256Generate SHA-256 checksums MD5 GeneratorGenerate MD5 hash values Text ToolsCase convert, count and transform text Number ConverterBinary, hex and octal converter Token CalculatorEstimate LLM token counts from text PDF EditorEdit text, sign and annotate PDFs Schema GeneratorJSON to TypeScript, Go, Rust, Python IndexNowSubmit URLs to Bing, Yandex & more PII RedactorMask personal data & keys before AI Timestamp ConverterUnix epoch to date and back UUID GeneratorUUID v4/v7, ULID, Nano ID Password GeneratorSecure passwords & passphrases MCP Config BuilderConfigs for Claude, Cursor, VS Code AGENTS.md GeneratorCLAUDE.md, Cursor rules, Copilot AI Crawler Controlsrobots.txt for AI bots & llms.txt Cron ParserExplain crontab, next run times SQL FormatterBeautify & minify SQL queries cURL ConvertercURL to fetch, Python, Go, PHP Chat Export ConverterChatGPT/Claude export to Markdown Markdown PreviewLive GFM preview & to HTML Color & ContrastHEX/RGB/OKLCH, WCAG checker QR Code GeneratorURL, Wi-Fi, vCard; PNG & SVG Image EditorConvert, compress, resize & crop Tool Schema ConverterOpenAI ↔ Anthropic ↔ Gemini ↔ MCP JSONL ValidatorFine-tuning & batch files SSE Stream ParserReassemble LLM streaming responses Prompt Template & DiffFill {{vars}}, compare versions