Tiktokenizer

Count tokens for GPT-4o, GPT-4.1 and o3 with tiktoken, plus open-weight models (Llama, DeepSeek, Qwen, Gemma, Mistral, Phi) with their real tokenizers — and estimated counts for Claude, Gemini and Grok. Chat-mode overhead and cost estimates, free, nothing leaves your device.

Token sourceo200k_base · 128k context
Token countUpdates as you type

Tokens

0

Characters

0

Words

0

Estimated input cost

$0.0000

list price $2.50 / 1M tokens, as of 2026-10 — check your provider

Tokenized text

Loading tokenizer…

Feeding docs to an AI support agent?

helpGPT ingests your Markdown, answers your customers' questions, and escalates to humans when it should.

Try helpGPT Free

Count GPT tokens before you hit the API

Paste text — or build a chat — and see the exact token count for GPT-4o, GPT-4.1, o3, GPT-4 and more, plus characters, words, and an estimated input cost at each model's list price.

Open-weight models, real tokenizers

Llama 3.1, DeepSeek-V3, Qwen2.5, Gemma 2, Mistral and Phi-4 are counted with the actual tokenizer files each model ships — SentencePiece and BPE — self-hosted on this site, not a rough chars-per-token guess. Claude, Gemini and Grok have no public tokenizer, so their counts are labeled ≈ and use o200k_base as a proxy.

How counting works, chat overhead included

Text is tokenized in your browser with the same byte-pair encodings OpenAI's models use. Chat mode adds the ChatML scaffolding every request carries — an <|im_start|> and role marker per message plus the trailing assistant primer — so the number reflects what the API actually bills.

Prices are estimates, not invoices

Cost figures use published list prices per 1M tokens; your provider may charge differently, so check your dashboard before budgeting. Token counting runs locally in your browser with the open-source js-tiktoken library — approach inspired by dqbd/tiktokenizer (MIT).

Frequently asked questions

What is a token?

The chunk language models actually read — usually a word, part of a word, or a few characters. API billing and context limits are measured in tokens, so counting before you send avoids surprises.

Why does the count differ between models?

Each model family uses its own tokenizer: GPT-4o, GPT-4.1 and o3 use tiktoken's o200k_base, while GPT-4 and GPT-3.5 use cl100k_base, and open-weight models like Llama, DeepSeek and Qwen ship their own SentencePiece tokenizers — all of which split the same text differently. Pick the model you will actually send the text to.

How is chat overhead counted?

Chat mode wraps each message in the ChatML scaffolding the API adds — <|im_start|> and role markers per message plus the trailing assistant primer — so the count reflects a real request, not just the visible words. It applies to OpenAI chat models, whose markup is public; other providers use different templates.

Why are Claude, Gemini and Grok counts approximate?

Those providers have not published their tokenizers, so an exact client-side count is impossible. Counts for them use OpenAI's o200k_base encoding as a proxy and are marked with ≈ — expect the real number to differ by a few percent to a few dozen percent depending on the text.

Does my text leave the browser?

No — tokenization runs entirely in your browser. OpenAI encodings load from the open-source js-tiktoken library and the open-weight tokenizers are self-hosted on this site, so nothing is uploaded, stored, or sent anywhere; there is no signup.

Related tools

Read the free PDF guides — step-by-step walkthroughs for everyday PDF work.