Text

LLM Token Counter and Context Planner

Count OpenAI tokens exactly and plan prompts, output reserves, context limits, and estimated API cost.

Free to use No sign-up Runs in your browser

Tool workspace

Counts are exact for the selected OpenAI tiktoken encoding. Claude, Gemini, and other tokenizers are not estimated here.

Processing stays in this browser.

Loading the selected tokenizer…

What Is an LLM Token and Context Planner?

This browser-local planner uses js-tiktoken to count text with the selected OpenAI encoding. It supports o200k_base and cl100k_base, includes model presets that set an encoding and context window, and separates system text, prompt text, and reserved output. A line or section breakdown helps identify expensive prompt regions. The tool does not claim exact tokenization for Claude, Gemini, or other providers because their tokenizers and message-accounting rules differ.

How to Count Tokens and Plan Context

  1. 1Choose an OpenAI model preset or directly select o200k_base or cl100k_base, then confirm the context-window limit.
  2. 2Paste the system instruction and user prompt or retrieved context into their labeled fields.
  3. 3Reserve enough output tokens, review the remaining context and line or section breakdown, and reduce text if the plan exceeds the limit.
  4. 4Optionally enter your current input and output prices per million tokens to estimate the planned request cost.

Token Planning Use Cases

Sizing retrieval-augmented prompts

Measure instructions, a question, and retrieved passages before sending them to an OpenAI model, while preserving room for the answer.

Finding oversized prompt sections

Compare token allocation by section or line to locate verbose examples, logs, or reference material that can be shortened.

Estimating API request cost

Apply prices from your own provider agreement or current pricing page instead of relying on hard-coded rates that may become outdated.

Frequently asked questions

Are these token counts exact?

They are exact for the selected o200k_base or cl100k_base encoding and the literal text entered. An API may add model-specific tokens for roles, tool calls, images, or other message structure, so leave a safety margin.

Can this count Claude or Gemini tokens?

No exact Claude or Gemini count is shown. Selecting a roughly similar OpenAI encoding would not reproduce those providers' tokenizers, so the tool avoids presenting such a result as accurate.

Does my prompt leave the browser?

No. Tokenization, budgeting, breakdowns, and cost arithmetic run locally in your browser; the tool does not upload the entered prompt.