CruxDevCruxDev Tools Prompts
dev Utility • Zero-Server Privacy • 100% Client-Side

Token Counter

Estimate tokens for current OpenAI, Claude, Gemini, Llama, and Mistral models. Exact BPE is labeled where available.

Overview

Count how many tokens a piece of text or a chat conversation will consume, per model, before you send it to an API. The GPT-4.1, GPT-4o, o3, o4-mini, GPT-4 and GPT-3.5 families get exact BPE counts computed locally; the newest GPT-5.6 models and other providers get clearly labeled estimates, plus context-window usage and cost figures where the model has them.

How It Works

Pick a model from the grouped dropdown, then choose an input mode: plain text or chat messages. In text mode, paste or type content and the token, character, and word counts update live. In chat mode, edit the role and content of each message, add or remove messages, and the counter adds the per-message structure overhead. The panel shows the count, whether it is an exact BPE count or an estimate, the percentage of the model's context window used when one is listed, and the cost of the input tokens at the model's static list price per million tokens, next to its output price and what the same count would cost as output. Models without a bundled context window or price show a note or a dash.

Step-by-Step Usage Guide

  1. Select the model you will send the prompt to.
  2. Switch between Text and Chat messages input mode.
  3. Paste your prompt, or edit the message list with roles and content.
  4. Read the token count, context-window percentage, and estimated input cost.

Technical Specifications & Standards

Two counting methods coexist, and the badge tells you which is in play. For the GPT-4.1, GPT-4o, o3 and o4-mini families the tool runs a byte-pair-encoding tokenizer entirely in the browser with the o200k_base vocabulary, and for GPT-4 and GPT-3.5 with cl100k_base (loaded on demand, so the badge reads approximate until it arrives), giving the same token count the API would compute. The GPT-5.6 models have no bundled tokenizer, so they are estimates like the other providers. For Anthropic, Google, Meta, Mistral and GPT-5.6 models there is no tokenizer bundled, so the tool divides character count by a per-model characters-per-token figure, about 3.5 to 4 (CJK characters count about one token each), and marks the result as an estimate. In chat mode the counter adds the overhead the OpenAI chat format introduces: three tokens of framing per message plus the role and content tokens, and three tokens priming the reply at the end. The cost card prices the counted tokens as input at a static snapshot of list prices (not live) and also shows what the same count would cost at the output rate; real output tokens are unknown in advance, and prices change often, so check the provider's pricing page. The tokenizer tables are large but bundled locally, so counting works offline and no text ever leaves the page.

Targeted Use Cases

  • Checking that a system prompt plus history fits inside a model's context window.
  • Estimating API cost for a batch of prompts before running them.
  • Comparing how many tokens different phrasings consume while prompt engineering.
  • Sizing chat transcripts that include role and delimiter overhead.

Notes & Gotchas

  • Use the model you actually call; vocabularies differ, and a cl100k count is not an o200k count.
  • Treat anything labelled approximate (non-OpenAI models and GPT-5.6) as a rough estimate and keep a safety margin near context limits.
  • Use chat mode when calling chat APIs, because bare-text counting omits per-message overhead.
  • Remember the main cost figure covers input tokens only; output tokens are billed separately, and the prices are a static snapshot.

Frequently Asked Questions

Why is my count exact for one model and an estimate for another?

OpenAI publishes BPE vocabularies for the GPT-4.1, GPT-4o, o-series, GPT-4 and GPT-3.5 families, so those get exact counts from the bundled tokenizer. GPT-5.6, Anthropic, Google, Meta, and Mistral have no bundled tokenizer, so the tool estimates from characters per token and labels it clearly.

Does chat mode count more tokens than the raw text?

Yes, deliberately. Chat APIs wrap each message in role tags and delimiters, costing three extra tokens per message plus three for reply priming, and the counter includes that structure.

Is my text uploaded for counting?

No. The tokenizer tables ship with the page and counting happens locally. Nothing you paste is transmitted.

What does the cost figure include?

The price of the input tokens you counted, at the static list-price snapshot for that model, plus the same count priced at the output rate for comparison. It excludes real output tokens and any provider-specific caching or tier discounts, and a few models show no price.