Skip to content
TabBench

LLM Token Counter

Calculate LLM tokens, context capacity, and estimated prompt API costs across OpenAI, Anthropic, and Google models.

Runs in your browser. Nothing you add is uploaded.

What the LLM Token Counter does

Language models do not process text in words or characters; they operate on tokens generated by Byte Pair Encoding (BPE) tokenizers. Calculating tokens before making API calls prevents context window truncation and unexpected cloud API charges. This tool estimates tokens, character counts, and exact prompt/completion pricing across OpenAI, Anthropic, Google, and Meta models.

How to count LLM tokens and estimate API costs

  1. Select your target model (GPT-4o, Claude 3.5 Sonnet, Gemini 1.5 Pro, Llama 3) from the dropdown.
  2. Paste your prompt, code snippet, system prompt, or RAG context into the editor.
  3. Review estimated tokens, total words, character count, and tokens-per-word metrics.
  4. Inspect the Context Window Capacity progress bar to ensure you are well within model limits.
  5. Compare prompt (input) vs completion (output) costs across all top models in the comparison table.

The LLM Token Counter runs entirely in your browser — nothing you enter is uploaded, stored, or logged.

When to use it

Optimizing System Prompts and Agent Instructions

Trim verbose phrasing from agent system prompts that run on every API interaction to reduce monthly recurring inference costs.

Context Window Capacity Verification

Verify that large codebases, PDFs, or conversational histories fit within model boundaries (e.g. 128k for GPT-4o, 200k for Claude 3.5).

API Budgeting & Production Cost Projections

Accurately project operational expenses before deploying AI features across thousands of daily active users.

Good to know

  • In general English text, 1 token is approximately 4 characters or ~0.75 words.
  • Code, JSON payloads, and specialized punctuation typically consume significantly more tokens per word than standard prose.
  • Everything runs locally in your browser: proprietary prompts and confidential documents are never sent anywhere.

Frequently asked questions

What is an LLM token?

Tokens are the basic units of text processed by language models. In English text, 1 token is roughly equivalent to 4 characters or about 0.75 words. Complex code or non-English scripts often require more tokens per word.

Are my prompt texts uploaded anywhere?

No. All token estimation and cost calculation happens locally in your browser's JavaScript engine. Your private system prompts and proprietary documents are never transmitted to any server.

Why do different models produce different token counts?

Each model provider trains its own tokenizer vocabulary (e.g., OpenAI's tiktoken o200k_base vs Anthropic's Claude tokenizer). Different vocabularies split words and subwords into different numbers of tokens.

Why are completion tokens more expensive than prompt tokens?

Generating output tokens requires autoregressive computation (predicting one token at a time), which consumes significantly more GPU compute than parallelized input prompt processing.
  • Image to Text (OCR)

    Copy text out of screenshots, scans and photos (OCR).

    Optional cloud mode

  • AI Code & Formula Explainer

    Plain-English explanations of formulas, calculations and code.

    Optional cloud mode

  • AI Text Summarizer

    Condense long text into a short summary or key bullet points.

    Optional cloud mode

  • AI Text Rewriter

    Rewrite text in a professional, friendly, concise or formal tone.

    Optional cloud mode