Tools

Token Calculator

Paste your prompt and see token counts and estimated cost for the models behind Claude Code and Codex, plus other popular models, so you can pick the right one and plan your budget.

  • Runs in your browser, nothing is uploaded
  • Free, no sign-up

Enter your prompt

Estimated entirely in your browser. Nothing is uploaded.

Examples:
238 characters1 lines

Parameters

Expected output length (relative to input)
Chat and support: about 1-2x. Code generation: about 3-5x. Long-form writing: up to 10x.
Calls per month
Monthly cost assumes the current text is sent this many times.
Claude Code input tokens63Estimated with Anthropic tokenization
Codex input tokens60Estimated with OpenAI tokenization
Lowest monthly cost$0.10GPT-6 Luna

Estimate

Based on 1,000 calls per month with output 3x the input. Rates are per million tokens.

±10% margin

Claude Code

Anthropic Claude models used by Claude Code

11 models
ModelRate (input / output)Input tokensOutput tokensPer callPer month
$10 / $5063189$0.0101$10.08
$10 / $5063189$0.0101$10.08
$2 / $1063189$0.00202$2.02
$2 / $1063189$0.00202$2.02
$5 / $2563189$0.00504$5.04
$5 / $2563189$0.00504$5.04
$4 / $2063189$0.00403$4.03
$5 / $2563189$0.00504$5.04
$5 / $2563189$0.00504$5.04
$3 / $1563189$0.00302$3.02
$1 / $563189$0.00101$1.01

Codex

OpenAI GPT models used by Codex

15 models
ModelRate (input / output)Input tokensOutput tokensPer callPer month
$4 / $2060180$0.00384$3.84
$2 / $1060180$0.00192$1.92
$8 / $4060180$0.00768$7.68
$2 / $1060180$0.00192$1.92
$2 / $1260180$0.00228$2.28
$0.2 / $1.260180$0.00023$0.23
GPT-6 LunaCheapest
$0.1 / $0.560180$0.00010$0.10
$2 / $1260180$0.00228$2.28
$1 / $560180$0.00096$0.96
$5 / $3060180$0.00570$5.70
$0.75 / $4.560180$0.00085$0.85
$1.75 / $1460180$0.00263$2.63
GPT-5.2 ProPriciest
$21 / $16860180$0.0315$31.50
$2.5 / $1560180$0.00285$2.85
$2 / $1060180$0.00192$1.92
Models from other providers14 models
ModelRate (input / output)Input tokensOutput tokensPer callPer month
$1.5 / $957171$0.00162$1.62
$2 / $1257171$0.00217$2.17
$1.32 / $3.9663189$0.00083$0.83
$0.3 / $1.263189$0.00025$0.25
$1.32 / $3.9663189$0.00083$0.83
$0.6 / $2.460180$0.00047$0.47
$0.3 / $1.260180$0.00023$0.23
$0.3 / $1.260180$0.00023$0.23
$1.4 / $4.460180$0.00088$0.88
$0.15 / $0.560180$0.00010$0.10
$0.15 / $0.560180$0.00010$0.10
$1.4 / $4.460180$0.00088$0.88
$3 / $1560180$0.00288$2.88
$0.95 / $460180$0.00078$0.78
With the current text and settings, GPT-6 Luna has the lowest monthly cost ($0.10).

Estimates use a character-based formula with roughly ±10% error. For exact counts, read the usage field returned by the API.

Use prompt caching

Claude Code and Codex both cache repeated context. Cached reads are billed at a much lower rate, which saves the most in long sessions.

Match the model to the task

Use a smaller model for routine edits and switch to a flagship or reasoning model for large refactors and hard bugs.

Trim your context

Include only the relevant code or document sections instead of the whole project. This often cuts tokens by half or more.

FAQ

What is a token, and why is usage billed by tokens?

A token is the smallest unit of text a model processes. An English word is usually 1-2 tokens and a Chinese character is 0.5-1 token. All major AI APIs bill by tokens rather than characters or requests, so understanding token usage is the first step in estimating the cost of an AI application.

How accurate is this estimate compared with a real tokenizer?

Vendors do not publish their tokenizers, or they are expensive to run in a browser, so this tool uses a character-based formula with roughly ±10% error. That is good enough for budgeting, price comparison and monthly cost planning. For exact numbers, read the usage field returned by the actual API.

Why are input and output calculated separately?

Every AI API prices input and output differently, and output usually costs 3-5 times as much as input. The total must be calculated from both parts, so the rate column shows the two prices side by side.

Why does my real Claude Code or Codex spend differ from this estimate?

Coding CLIs call the model many times in one task and resend the same context again and again. Cached parts are billed at a lower cache rate, while repeated calls push total tokens far above a single prompt. This tool estimates the cost of sending the same text repeatedly, which is useful for comparing models against each other, but it is not the bill for a full coding session.

How can I lower my AI API costs?

1) Match the model to the task: a smaller model for routine edits and a flagship model only for hard problems. 2) Use prompt caching for system prompts and fixed context. 3) Trim context to the relevant parts. 4) Batch requests. 5) Cache answers to common questions instead of regenerating them.

Put these to work in real AI projects

AnBoWork is a graphical workbench for the official command lines such as Claude Code and Codex: it manages accounts and models in one place and renders command-line sessions as a chat interface.