Token counter · Free LLM token counter for OpenAI, Claude & Gemini · mdream

[Home](https://mdream.dev/tools/token-counter/)

# Token counter

Count tokens for ChatGPT, Claude, Gemini, and Llama. Paste text, HTML, or a URL; we show counts across every major tokenizer and how many tokens you save by converting HTML to Markdown with [mdream](https://mdream.dev/tools/token-counter/).

TEXT

HTML

URL

Tokenizer estimates belowCount

zzz

Ready

Paste text, HTML, or a URL to count tokens.

## How mdream reduces tokens

Every HTML page carries tag overhead that tokenizers charge you for. Converting to focused markdown before the LLM sees it keeps the context and drops the tax.

1. 1 ### Convert HTML to markdown

   mdream strips scripts, nav, footers, and inline styles. What remains is the content an LLM actually needs.
2. 2 ### Tokenize both sides

   We estimate cl100k_base, o200k_base, Llama 3, and Gemini counts so you can see the delta per model family.
3. 3 ### Compare and save

   Typical pages drop 50–80% of tokens after conversion. That's real money back on every LLM call.

## Which tokenizer?

- cl100k_base — official OpenAI BPE, exact. GPT-3.5, GPT-4, and a very close approximation for Claude 3 & 3.5. Use this if you're unsure which model you're targeting.
- o200k_base — official OpenAI BPE, exact. GPT-4o and GPT-4o-mini. Roughly 8% fewer tokens than cl100k_base on English text.
- llama3 — estimate. Meta Llama 3's tokenizer isn't open; we scale cl100k by +8% based on published vocab size.
- gemini — estimate. Google hasn't released Gemini's SentencePiece; we use a char-frequency heuristic. Treat this column as a ballpark.

## Frequently Asked Questions

Which tokenizer does this use?

GPT-4, GPT-3.5, and Claude 3+ counts come from OpenAI's official cl100k_base BPE vocabulary via gpt-tokenizer; GPT-4o counts use o200k_base. These are exact. Llama 3 and Gemini tokenizers are not publicly released, so those columns are heuristic estimates calibrated against published model documentation.

Why do HTML tokens differ so much from markdown tokens?

HTML carries tag overhead (class names, inline styles, script tags, nav menus, cookie banners). LLM tokenizers count every angle bracket, attribute, and piece of whitespace. Markdown strips all of that, keeping only the content an agent needs to answer a question.

Is my input stored?

No. Text, HTML, and URL inputs are tokenized in-flight on a Cloudflare Worker and discarded on response. Nothing is logged or persisted.

How does this compare to OpenAI's tokenizer playground?

OpenAI's tokenizer only counts one tokenizer at a time and only accepts plain text. This tool also fetches URLs, runs mdream's HTML-to-markdown pipeline, and shows the token delta across four tokenizer families side by side.

Can I count tokens for Claude?

Yes. Anthropic has stated Claude 3 and 3.5 use a tokenizer very close to OpenAI's cl100k_base. For most content, the cl100k_base column is within a few percent of Anthropic's official count.

## Related

[<h3>mdream</h3>Convert HTML to Markdown.](https://mdream.dev/tools/token-counter/) [<h3>Converters compared</h3>mdream vs Turndown vs node-html-markdown.](https://mdream.dev/tools/token-counter/tools/compare) [<h3>AI visibility audit</h3>Is your site ready for AI agents?](https://mdream.dev/tools/token-counter/tools/ai-audit)

© 2026 [Harlan Wilton](https://github.com/harlan-zw) · [MIT](https://github.com/harlan-zw/mdream/blob/main/license)

[GitHub](https://github.com/harlan-zw/mdream) [Discord](https://discord.com/invite/275MBUBvgP)