Token counter & LLM cost calculator
Paste your prompt to count tokens, estimate what it costs to run through an API, and see the local hardware that breaks even against that spend. Counting is exact for OpenAI models and approximate for Claude - labelled honestly in the results.
Estimated cost
Live as you type - no request sent, all counted in your browser
Across other models
Per-token prices are list/reference rates - verify against the provider's current pricing before committing. Catalog prices carry their verified date; frontier prices were checked September 2026.
Estimate a coding task
"I have a codebase this big - what will this feature / refactor cost to run through an LLM?"
The other counter answers "what does this prompt cost per month?" This one answers the question you ask before greenlighting agentic work: roughly what will it cost to run a refactor or new feature over a codebase this size. Pick a task size most people recognize - bugfix, small feature, large refactor - and the lines of code involved. The number is a first-principles napkin estimate, not a quote; adjust the assumptions to match how your agent actually works.
Across other models
One-shot project estimate, not a recurring bill. The agent reads your codebase context several times and writes back changes - this multiplies lines by ~10 tokens/line, by read passes, and by the per-token price. Real cost varies with your agent, caching, and how much code it actually touches; adjust the assumptions above. Prices are list/reference - verify against the provider before committing.
Doing this kind of work regularly? A one-shot API bill is easy to justify once. The recurring spend is what adds up - for the same money, you could own hardware outright and run an open-weight model locally with no per-token bill and no codebase leaving your network.
See the local rig that breaks even →Run it locally instead
The move no other token calculator makes
That monthly API spend is a running cost that never ends. For the same money you could buy hardware outright and run an open-weight model locally - no per-token bill, no data leaving your network. See what rig breaks even against your current spend.
See the local rig that breaks even → Or skip the ops - managed private AI →Join free to match this budget against hardware you already own.
How the math works
First-principles cost estimation, the napkin-math way
Monthly cost comes from four numbers multiplied through:
(input tokens / request) × (requests / day) × 30 × ($ / 1M input tokens) ÷ 1,000,000
+ (output tokens / request) × (requests / day) × 30 × ($ / 1M output tokens) ÷ 1,000,000
That is the whole shape. Count the tokens, multiply by your volume and the per-token price. This kind of first-principles estimation - get the order of magnitude before you reach for a spreadsheet - is the method Simon Eskildsen collects at napkin-math (notes, MIT-licensed reference numbers revalidated on real cloud hardware). It is the same instinct that let turbopuffer prove vector search could be built far cheaper than incumbents charged - and turn it into one of Canada's fastest-growing AI companies.
We apply a 0.8 shared-seat factor for teams (not every seat fires at full rate at once), matching the assumption our budget tool uses so the two pages agree.
Reference numbers and the napkin-math method are Eskildsen's work - we point to it, we did not invent it.
FAQ
How many tokens are in 1,000 words?
Roughly 1,250 to 1,500 tokens for 1,000 words of English text, depending on the tokenizer. Modern OpenAI models use the o200k tokenizer; paste your text above for an exact count. Code, non-English text, and punctuation expand the token count.
How much does 1 million tokens cost?
It depends on the model. As of July 2026, GPT-5.4 is $2.50 per 1M input tokens and $15 per 1M output; Claude Sonnet 5 is $2 per 1M input and $10 per 1M output (intro pricing through Aug 31 2026); Claude Haiku 4.5 is $1 per 1M input and $5 per 1M output. Cached input is cheaper where the provider offers prompt caching. Always verify against the provider's current pricing page.
How do I estimate LLM API cost?
Multiply tokens by the per-token price. Monthly cost = (input tokens per request x requests per day x 30 x input price per 1M / 1,000,000) plus the same for output. The calculator above does this live as you type. The napkin-math section below explains the first-principles version.
Is this token counter exact for GPT and Claude?
Exact for OpenAI models that use the o200k tokenizer (GPT-4o, GPT-4.1, GPT-5 family) and cl100k (GPT-4, GPT-3.5). Claude does not publish a tokenizer, so Claude counts are approximate, labelled as such in the UI. Open-weight models (Llama, Qwen, GLM) have their own tokenizers; counts shown are an o200k proxy and labelled approximate.
What can I do if my API cost is too high?
Three levers: cache prompts where the provider supports it (cached input is up to 90% cheaper), move static workloads to a cheaper or open-weight model, or run the model locally. The bridge below shows the local hardware that breaks even against your current monthly API spend.
How much does an LLM codebase refactor cost?
Roughly: lines of code times ~10 tokens/line times the number of times the agent re-reads that context (read passes) times the input price, plus the rewritten/added lines times the output price. A medium feature over a 50k-line codebase with GPT-5.4 is on the order of $10-15 one-shot before caching; a large refactor over 500k lines is on the order of $100-200. The codebase-task estimator above does this napkin math live and lets you adjust every assumption. Real cost varies with your agent, caching, and how much code it actually touches.
How many tokens is a line of code?
About 10 tokens per line for source code on modern tokenizers (o200k). Code is token-dense - identifiers, punctuation, and symbols all count. The exact count varies by language and tokenizer; paste a file into the counter above for an exact OpenAI count, or use ~10 tokens/line as the napkin figure for project-level estimates.