Free No sign-up Client-side

AI Token Counter

Count tokens and estimate API costs for GPT-4o, Claude 3.5, and Gemini 1.5 — paste your prompt, pick your model, get the token count and cost instantly.

0 chars0 words

0

Input tokens

500

Output tokens

$0.007500

Est. total cost

0%

Context used

500 tokens
50 (short)2,000 (medium)4,000 (long)
Cost Breakdown — GPT-4o
Input (0 tokens @ $5/1M)$0.000000
Output (500 tokens @ $15/1M)$0.007500
Total per call$0.007500
Context window usage500 / 128,000 tokens (0%)

GPT-4o supports up to 128K tokens. Within limit.

Cost comparison across models

GPT-4o
$0.007500
GPT-3.5 Turbo
$0.000750
Claude 3.5 Sonnet
$0.007500
Gemini 1.5 Pro
$0.005250
Paste your prompt above to see the token count and cost estimate.

What is an AI token?

Large language models (LLMs) like GPT-4o, Claude, and Gemini do not process text word by word — they process tokens. A token is a chunk of text that the model's tokenizer splits the input into before feeding it to the neural network. One token is roughly 4 characters or ¾ of an English word on average, but the exact split depends on the tokenizer each model uses.

Why does this matter? Every LLM API charges per token, not per character or per request. A prompt that looks short can cost significantly more than expected if it contains code, special characters, or rare words that tokenize less efficiently. Before running a large batch job or setting a context window limit, knowing the exact token count saves you from surprise bills.

This tool gives you an instant token estimate for the most popular LLM APIs — GPT-4o, Claude 3.5 Sonnet, and Gemini 1.5 Pro — along with the cost for both input (your prompt) and output (the model's response, at the length you specify). Everything runs locally in your browser; your prompt text is never sent anywhere.

How to use the token counter

  1. 1

    Paste your prompt

    Type or paste your system prompt, user message, or any text into the editor. The token count updates instantly.

  2. 2

    Select a model

    Choose the model you plan to use: GPT-4o, GPT-3.5 Turbo, Claude 3.5 Sonnet, or Gemini 1.5 Pro.

  3. 3

    Set expected output length

    Drag the output tokens slider to estimate how long the model's reply will be. The cost estimate updates accordingly.

  4. 4

    Compare costs

    Switch between models to see the cost difference for the same prompt. Use this to pick the right model for your budget.

Why developers count tokens before calling the API

Avoid unexpected bills

A 100K-token batch job against GPT-4o costs far more than GPT-3.5 Turbo. Know the cost before you commit.

Stay within context limits

GPT-4o supports 128K tokens. Claude 3.5 supports 200K. Knowing your prompt length ensures you don't hit the limit mid-generation.

Optimise prompt engineering

Trim verbose system prompts and cut costs without reducing quality by seeing exactly which parts consume the most tokens.

Plan retrieval-augmented generation (RAG)

Estimate how many retrieved chunks fit in the context window alongside your question for smarter RAG pipeline design.

Token count examples

Short prompt
Summarise this article in 3 bullet points.
~9 tokens

Simple English sentences tokenise efficiently — roughly 1 token per word.

System prompt with JSON schema
{"role":"system","content":"You are a helpful assistant. Always respond in valid JSON matching this schema: {\"name\": string, \"age\": number}"}
~45 tokens

JSON keys, quotes, and escape characters each consume tokens — JSON schemas cost more than equivalent English prose.

How token counting works (without a server)

Exact tokenisation requires running each model's specific tokenizer library. OpenAI uses tiktoken (a Rust/WASM library). Anthropic and Google use their own internal tokenizers that are not publicly released as standalone tools. Running these in a browser without a backend is not feasible for exact counts.

This tool uses a well-established approximation: 1 token ≈ 4 characters for standard English text, with a small correction for whitespace and punctuation. For typical prompts in English, this approximation is accurate to within 5–10%. For code, JSON, or non-English text, the actual token count may differ — use the estimate as a guide, not a guarantee.

For exact counts in production, use OpenAI's tiktoken library in Node.js, Anthropic's token counting API endpoint (/v1/messages/count_tokens), or Google's countTokens method in the Vertex AI SDK.

LLM pricing reference (as of 2026)

  • GPT-4o: $5.00 / 1M input tokens · $15.00 / 1M output tokens
  • GPT-3.5 Turbo: $0.50 / 1M input tokens · $1.50 / 1M output tokens
  • Claude 3.5 Sonnet: $3.00 / 1M input tokens · $15.00 / 1M output tokens
  • Gemini 1.5 Pro: $3.50 / 1M input tokens · $10.50 / 1M output tokens
  • Prices change — always check the official pricing page of each provider before billing-critical decisions.

Frequently asked questions

It is a close approximation — typically within 5–10% for English text. It uses the rule of thumb that 1 token ≈ 4 characters. For exact counts, use OpenAI's tiktoken, Anthropic's /v1/messages/count_tokens API, or Google's countTokens SDK method.

No. All counting and cost calculation happens entirely in your browser using JavaScript. Your prompt text never leaves your device.

GPT-4o: 128,000 tokens. GPT-3.5 Turbo: 16,385 tokens. Claude 3.5 Sonnet: 200,000 tokens. Gemini 1.5 Pro: 2,000,000 tokens. These are total context limits — your input + output must fit within them.

Approximately 1,333 tokens. The 1 token ≈ ¾ word ratio is a reliable rule of thumb for standard English prose.

Code contains many special characters (brackets, semicolons, underscores), camelCase identifiers, and short tokens that don't map cleanly to the tokenizer's vocabulary. This often results in more tokens per character than plain English.

Use concise system prompts, avoid redundant instructions, use bullet points instead of full sentences where possible, and remove unnecessary examples from few-shot prompts. For RAG pipelines, trim retrieved chunks to only the most relevant sentences.

Need another tool?

Browse the full toolbox or dig into the blog for the engineering behind it.

Call UsWhatsApp