iLoveMD
100% in your browser

Markdown Token Counter

Paste Markdown or any text to see its GPT-4o, Claude, and Llama token counts. GPT-4o is exact; the tokenizer runs in your browser, so your text never leaves your device.

  • Always free
  • No uploads
  • No sign-up
  • No tracking

← All conversion tools

Token counter .md
No files selected

Your Text

Token Count

Export Your Results

Markdown Token Counter Docs

A token is the unit a large language model actually reads — roughly a word-piece. This tool counts tokens for any text or Markdown you paste, so you know how much of a model's context window you are using before you send it. GPT-4o counts are exact (the real tokenizer runs locally in your browser); Claude and Llama are clearly-labeled estimates. Everything runs on your device — your text is never uploaded.

What is a token?

Language models don't read characters or whole words — they read tokens, which are word-pieces produced by a byte-pair-encoding (BPE) tokenizer. Common words are usually one token; longer or rarer words split into several. As a rough rule of thumb for English, one token is about 4 characters or 0.75 words — but punctuation-dense Markdown, code, and non-English text tokenize differently, which is why an exact count matters.

Pricing, rate limits, and context windows are all measured in tokens, not words. Knowing the token count before you paste a document into a chat or an API call tells you whether it will fit and what it will cost.

GPT-4o is exact — here's how exact

For the GPT family we run the real o200k_base tokenizer — the same byte-pair encoding GPT-4o, GPT-4.1, GPT-5, and the o-series use — entirely in your browser. The encoder is a vendored, version-pinned JavaScript bundle served from this domain; it loads once, on demand, the first time you count. After that the number is exact, character-for-character with what the model sees.

No network call is involved in the counting itself. The tokenizer is local code, the text stays on your machine, and the count is produced offline.

Why Claude and Llama are estimates estimate

Anthropic does not publish a client-side tokenizer for Claude 3+ or Claude 4 — the only exact source is their server-side count_tokens API, which means sending your text over the network. We will not do that: it would break the "your text never leaves your device" promise that this whole site is built on. Llama's SentencePiece tokenizers are public but vary by model and are heavy to ship for a glanceable counter.

So Claude and Llama are shown as estimates (marked with ), derived from the text's character and word counts using ratios tuned for English. They are usually within ~10–15% of the true count — fine for "will this fit in the context window?" decisions, not a billing-grade figure. If an official client-side tokenizer ships for either, we'll swap the estimate for an exact count.

Input vs. output, and what gets counted

On this standalone tool you paste one block of text and see its counts across all three model families, plus word and character totals.

Inside the main converter, the token counter shows both the input and the output — because when you convert Markdown to HTML, the output is markup an AI builder rarely feeds to a model; the input Markdown is what matters. Counting both sides means the number you care about is always on screen, whichever direction you're converting.

Limits & privacy

  • Exact-count ceiling: inputs above ~1 MB fall back to an estimate rather than freezing the tab — the exact tokenizer runs synchronously, and that's a safe ceiling for a live counter.
  • No uploads, no API, no tracking: the tokenizer is local code; your text is never sent anywhere.
  • Works offline once the page (and, on first count, the tokenizer bundle) has loaded.

How to count tokens in Markdown

1

Paste your text

Paste Markdown or any text into the box on the left. Nothing is uploaded — the counter runs in your browser.

2

Read the counts

See exact GPT-4o tokens plus Claude and Llama estimates, with word and character totals, updating as you type.

3

Check it fits

Compare against your model's context window before pasting the text into a chat or an API call.

Frequently asked questions

Are the GPT token counts exact?

Yes. We run the real o200k_base tokenizer (used by GPT-4o, GPT-4.1, GPT-5, and the o-series) locally in your browser, so the GPT-4o count matches what the model sees.

Why are Claude and Llama only estimates?

There is no official public client-side tokenizer for Claude 3+/4, and the only exact source is a server API that would require uploading your text — which we will not do. Claude and Llama are shown as labeled estimates, usually within about 10–15% of the true count.

Does my text get uploaded anywhere?

No. The tokenizer is local JavaScript. Your text is never sent to a server, an API, or any third party.

What is a token?

A token is a word-piece — the unit a language model actually reads. As a rough rule, one token is about 4 characters or 0.75 words of English, but the exact count depends on the tokenizer.

Does it work offline?

Yes, once the page has loaded. The GPT tokenizer bundle loads once on your first count, then everything runs locally without an internet connection.