Free tool

Token Counter & AI Cost Estimator

Paste any text to get a fast token estimate and see what it would cost to run through popular LLM APIs. Useful before you send a huge prompt.

If you work with LLM APIs you already know the math: tokens are money, and most of us are bad at guessing how many a given block of text will cost. Paste your prompt or document below and you will get an instant character, word, and token count, plus a cost estimate against the current pricing for GPT-4o, Claude Opus 4.1, Claude Sonnet 4.5, and Google Gemini. Switch models from the dropdown to compare. The token count is an approximation (roughly four characters per token), good enough for planning but not for invoicing. If you are about to push a PDF or DOCX through an API, it is almost always cheaper to convert it to Markdown first; we link to a write-up with the real numbers below. Nothing you type leaves your browser.

·

Token count is approximated at ~4 characters per token. Accurate enough for planning, not for invoicing.

Using the Token Counter in practice

The fastest way to use this tool is as a sanity check before you call an LLM API. Drop in your system prompt, your user message, and any context you plan to stuff into the request. The counter will tell you, at a glance, whether you are about to send 2,000 tokens or 40,000. That matters because costs scale linearly and context windows have hard limits. A Claude Sonnet call with a 100-page attached PDF can quietly burn through a few dollars per request if you are not watching.

A concrete example. Say you are preparing a 40-page employee handbook for a ChatGPT knowledge base so HR can answer policy questions from the chat. If you attach the raw PDF (OCR noise, page headers and footers, repeated nav strips) you are probably looking at 45,000 input tokens per query once the knowledge base injects the context. Convert the same handbook to clean Markdown first using a tool like ours and you typically land at 16,000 to 22,000 tokens for the same content. Run that 200 times a day across every policy question the company asks, and the savings pay for the converter many times over. The blog post on real token cost numbers walks through specific document types and the percent savings you can expect.

A second example. You are building a RAG pipeline and retrieving ten chunks per query. Paste one average chunk in here, multiply by ten, add your system prompt, and you know the floor on per-query input cost before you even write any code. If output responses average 400 tokens, the input-plus-output total at the bottom of this page is your per-query estimate. Multiply by expected query volume and you have a budget.

A quick word on accuracy. The roughly-four-characters-per-token rule is tuned for English prose. Code, structured data, and non-Latin scripts all tokenize differently, sometimes dramatically so. For code-heavy text, expect this tool to undercount by 10 to 20 percent. For Chinese, Japanese, or Arabic, tokenizers vary by vendor and you should trust the provider's own tokenizer for anything billable. For day-to-day planning on English prose, the estimate here is typically within a few percent of tiktoken.

For non-English prose, trust the vendor tokenizer for anything billable.

If you want to go deeper on why Markdown is the most token-efficient format for LLM input, see How to cut LLM token costs with Markdown and the comparison post PDF vs Markdown: the AI token tax. If you have a stack of PDFs to convert, our PDF to Markdown converter handles them in bulk.

How to use this tool

  1. 1

    Paste or type text into the box. Counts update live as you type.

  2. 2

    Pick a model from the dropdown to see input and output pricing for that specific model.

  3. 3

    Use the input-only total for a prompt cost, or the input plus output total to model a full round-trip.

  4. 4

    If the number surprises you, try converting your source file to Markdown first; it usually cuts tokens by a third or more.

Frequently asked questions

How accurate is the token count?+

It is an estimate, not a true tokenizer. We use the well-known roughly-four-characters-per-token rule for English text. Real tokenizers (tiktoken for OpenAI, Anthropic's tokenizer, Google's for Gemini) will differ by a few percent, and more for code, non-English text, or very short strings. If you need exact counts for billing, use the provider's official tokenizer.

Why do the prices differ from what I see on the provider website?+

Model pricing changes. The numbers here are per-million-token rates published by OpenAI, Anthropic, and Google as of late 2025 / early 2026. Always confirm with the provider before making budget decisions. This tool exists to help you make order-of-magnitude choices, not to replace a finance tool.

What is the difference between input and output tokens?+

Input tokens are what you send to the model (the prompt, system message, attached documents). Output tokens are what the model sends back (the completion). Output tokens are typically priced 3x to 5x higher than input tokens, which is why long AI-generated answers get expensive fast.

Does this tool send my text anywhere?+

No. Everything happens in your browser. Nothing is uploaded, stored, or logged on our side. You can disconnect from the internet after the page loads and it will keep working.

Why does converting to Markdown save tokens?+

Raw PDFs, DOCX, and HTML contain a lot of formatting noise and repeated whitespace that costs tokens but does not help the model. Clean Markdown often uses 30 to 60 percent fewer tokens for the same content. We wrote up the real numbers on the blog; see the related links below.

Can I paste code or non-English text?+

You can, but the estimate will be less accurate. Real tokenizers split code and non-Latin scripts differently. Expect the estimate to be off by 10 to 30 percent for code-heavy or multilingual input. Use it as a rough guide.

Related tools

Related learning

Need to convert real files to Markdown?

This tool is a free helper. For full PDF, Word, Excel, PowerPoint, EPUB, and image conversion with AI-ready output, create a free account.