3tej home

What is GPT + Claude Token Counter?

A GPT + Claude Token Counter computes gpt + claude token counter from the inputs you provide. It applies the standard formula to the values you enter and returns the result instantly, without sending any data to a server. Counts tokens client-side and shows input + output + round-trip cost.

GPT + Claude Token Counter

Paste a prompt, see token count and cost across GPT-4o, GPT-4o mini, Claude Sonnet 4.5, Claude Haiku 4.5, and Gemini 2.0 Flash.

🔒 Browser-only ⚡ Instant 💸 Free forever 📡 Works offline 🚫 No signup
← Utilities

TLDR

Paste any text, pick a model, see token count and the cost at input price, output price, and round-trip price. Estimates use a heuristic of 4 chars/token for English, 2.7 for code, and 3.2 for JSON. For exact counts on OpenAI models use OpenAI's tokenizer; this tool is for budgeting and pre-flight checks.

Runs entirely in your browser. No upload, no signup, no logging. Output is for personal or commercial use; we don't claim any rights.

How to use this tool

  1. Enter your inputs. Each field is labeled with what it expects.
  2. Read the result instantly. Numbers update as you type or change inputs.
  3. Adjust to test sensitivity. Change one input at a time to see what moves the result most.
  4. Cross-check the formula in the section below if you want to verify the math.
  5. Copy or screenshot the result for later. The site does not save anything; close the tab and inputs are gone.

About this tool + how it works

This tool runs 100% in your browser - the libraries load from a public CDN and the math runs on your device. Nothing is uploaded to a server. The underlying logic is:

tokens = chars / chars_per_token  (4.0 English, 2.7 code, 3.2 JSON, 3.7 mixed)
input_cost  = tokens * input_price_per_million / 1,000,000
output_cost = tokens * output_price_per_million / 1,000,000
round_trip  = input_cost + output_cost  (assumes same-size response)

You can verify by opening the browser developer tools and watching the Network tab; you'll see no requests fired during normal use beyond the initial page and library load.

Real-world scenarios where this tool helps

Budget a feature before shipping

You're about to wire GPT-4o into a workflow. Paste a typical user input and the prompt template; multiply by expected calls per day to get monthly cost.

Compare model pricing

Same prompt, different model. See the cost gap between GPT-4o and GPT-4o mini, or Claude Sonnet vs Haiku.

Stay under context windows

Token count helps you confirm a prompt fits inside the model's context window before you send it.

Estimate API spend for clients

Building an AI feature for a client? Paste their typical input, count tokens, give them a per-call and per-month cost estimate.

What this tool does

  • Counts tokens for any text using a content-type-aware heuristic.
  • Supports GPT-4o, GPT-4o mini, Claude Sonnet 4.5, Claude Haiku 4.5, and Gemini 2.0 Flash.
  • Computes cost at input price, output price, and round-trip (input + same-size output).
  • Shows cost per 1,000 calls so you can quickly estimate monthly burn.
  • Reports word count and character count alongside tokens.

What it does NOT do

  • Doesn't tokenize using the exact model tokenizer client-side. The tool uses a heuristic (chars/token); for exact counts use OpenAI's tokenizer or Anthropic's count_tokens API.
  • Doesn't include cached input pricing (Claude prompt caching can cut input cost 90%).
  • Doesn't include batch API pricing (50% discount on OpenAI's Batch API).
  • Doesn't account for vision tokens (image inputs are billed differently).
  • Doesn't store anything - close the tab and your text is gone.

Common mistakes and pitfalls

  • Forgetting that output tokens cost more than input. A model that returns long answers can flip your budget.
  • Assuming the heuristic matches the real tokenizer to the dollar. Real counts can be 5-15% off either way; budget with a margin.
  • Pasting a 'rare characters' or non-English language test and expecting the heuristic to match. Asian languages and emoji can be 1-3 tokens per character.
  • Forgetting system prompt and tool definitions. Those count too and they can dominate small user prompts.
  • Comparing only API price; some models are 5x faster, which matters for UX even if the per-token price is higher.

Frequently asked questions

How accurate is the token count?

It's a heuristic. For English prose, it lands within about 5% of the true count. For code, JSON, or non-Latin scripts, it can be off by 10-20%. Use OpenAI's official tokenizer at platform.openai.com/tokenizer if you need exact counts.

Why no exact tokenizer in the browser?

OpenAI's o200k_base and Anthropic's tokenizers ship as large data files (>2 MB each). Loading them just to count tokens makes the page slow. The heuristic is good enough for budgeting.

What are the current prices?

GPT-4o: $2.50 input / $10 output per 1M tokens. GPT-4o mini: $0.15 / $0.60. Claude Sonnet 4.5: $3 / $15. Claude Haiku 4.5: $1 / $5. Gemini 2.0 Flash: $0.10 / $0.40. Always confirm on the model card.

What is round-trip cost?

The cost of one full request: your input tokens charged at input rate plus an equal-size response charged at output rate. Approximates the cost per chat exchange.

Does it count system prompts?

Whatever you paste, it counts. Paste your full prompt including system message, examples, and user input for an accurate quote.

How does Claude prompt caching change cost?

Anthropic's prompt caching can cut cached input tokens to 10% of full input rate after the first call. If your system prompt is reused, real cost can be 50-80% less than this calculator shows.

Why does the same text count differently across models?

Each model has its own tokenizer. GPT-4o uses o200k_base (more efficient for code and many languages); Claude uses cl100k_base; Gemini uses its own. The heuristic is averaged.

Is my pasted text saved?

No. The tool runs entirely in your browser. Close the tab and the text is gone. Nothing is sent to a server.

Can I use this for embedding cost?

Embedding pricing is much lower (typically $0.02-$0.13 per 1M tokens). The same token count works; just multiply by the embedding price.

What about image and audio tokens?

Vision and audio inputs use different token math (often 85-1,275 tokens per image depending on resolution). This calculator only handles text.