Private LLM Token Counter

Updated October 2026

Paste text or drop a file to count its tokens in OpenAI's two current encodings: o200k_base (GPT-4o, GPT-4.1, GPT-5, o1, o3, o4-mini) and cl100k_base (GPT-4, GPT-3.5 Turbo, the text-embedding-3 models). Your text is never uploaded: it is tokenized in your browser with the same byte-pair encoding tables OpenAI's tiktoken uses.

.txt, .md, .json or .csv, up to 20 MB. Read on your device, never uploaded.

The tokenizer (about 1.5 MB) loads from larely.com when you start typing.

Tokens · o200k_base
0
GPT-4o, GPT-4.1, GPT-5, o-series
Tokens · cl100k_base
0
GPT-4, GPT-3.5 Turbo, embeddings
Characters
0
Unicode code points
Words
0
Browser word segmentation
UTF-8 bytes
0
What the tokenizer reads

Show token boundaries

Estimate cost

Cost of this text at that price Enter a price

No prices are built in, because they change. Input and output tokens are usually priced differently, so use the rate for the side you are estimating.

Claude and Gemini: rule-of-thumb estimates only

Neither tokenizer is public. These figures apply each vendor's published characters-per-token rule to your character count. They are not counts, and they drift badly for code, numbers and non-English text.

Gemini (Google: “about 4 characters” per token)—
Claude before Opus 4.7 (Anthropic: about 3.5 English characters per token)—
Claude Opus 4.7 and later (Anthropic: about 30% more tokens than that)—

Exact counts: Anthropic count_tokens (free) · Google countTokens.

Which OpenAI models use o200k_base and which use cl100k_base

OpenAI's tokenizer library, tiktoken, maps model names to encodings in one file, tiktoken/model.py. As of the 2026-08-17 revision of that file, the mapping for current models is:

EncodingModels (exact names or name prefixes in model.py)
o200k_baseAny name starting gpt-5; gpt-4.5-; gpt-4.1; gpt-4o and chatgpt-4o-; o1, o3, o4-mini; fine-tuned ft:gpt-4o
cl100k_basegpt-4 and gpt-4- variants (including gpt-4-turbo); gpt-3.5-turbo; text-embedding-3-small, text-embedding-3-large, text-embedding-ada-002; davinci-002, babbage-002
o200k_harmonygpt-oss- open-weight models. It uses o200k_base's vocabulary and splitting rules and only adds chat-formatting special tokens, so the o200k_base count above applies to plain text.

If a model you use is not in that file, tiktoken refuses to guess and raises an error. Check the model's documentation before assuming an encoding.

What a token looks like, with real examples

A token is an entry in the model's vocabulary: often a whole common word with its leading space, sometimes a word fragment, a punctuation mark or a single byte. Every count below was produced by this page's tokenizer, and you can reproduce any of them by pasting the text above and turning on the token view.

TextCharacterso200k_basecl100k_base
hello world1122
The quick brown fox jumps over the lazy dog.441010
2026-10-261066
{"id": 42, "name": "Ada"}251212
Größenverhältnis1658
Привет, как дела?1768
日本語のテキスト868
👍113

Two things stand out. For plain English the encodings tie, so moving an English prompt from GPT-4 to GPT-4o barely changes its count. For German, Russian, Japanese and emoji, o200k_base is clearly cheaper, because its larger vocabulary gives more of those character sequences their own entry. Dates and JSON punctuation cost more than their length suggests: 2026-10-26 is 6 tokens for 10 characters. The guide JSON vs CSV vs YAML: token cost measured applies this to whole datasets.

Counting tokens for Claude and Gemini

Anthropic and Google do not publish the tokenizers behind their current models, so no client-side tool can give you their exact numbers. What they do publish is a rough ratio and a counting API:

  • Gemini: Google's token documentation says a token “is equivalent to about 4 characters” and that 100 tokens are “about 60-80 English words”. Exact counts come from the countTokens method of the Gemini API.
  • Claude: Anthropic's glossary says a token represents about 3.5 English characters on models before Claude Opus 4.7, and that Opus 4.7 and later use a newer tokenizer that produces about 30% more tokens for the same text. Exact counts come from the /v1/messages/count_tokens endpoint, which Anthropic lists as free to use, with its own rate limits.

The estimate panel in the tool applies those ratios literally to your character count. Treat them as a sanity check for English prose. For a budget or a context-window limit, call the vendor's endpoint with the exact model ID.

What the count does not include

This page counts the text you give it, nothing more. A real API request costs more than its text:

  • Message framing. Chat requests wrap every message in a few formatting tokens. OpenAI's cookbook example adds 3 tokens per message plus 3 to prime the reply for the models it covers, and says outright that the method may change between models and is an estimate.
  • Tools and images. Function or tool definitions are added to the prompt and billed as input tokens. Images are billed under their own rules, which this page does not model.
  • Output. Generated tokens are billed separately, often at a different rate from input. The cost box multiplies whatever price you enter by the count you pick, so enter the input rate for a prompt.

How to check these counts yourself

OpenAI's reference implementation is the Python package tiktoken. With Python installed, this prints the token IDs for hello world in cl100k_base:

pip install tiktoken
python -c "import tiktoken; print(tiktoken.get_encoding('cl100k_base').encode('hello world'))"

Expected output: [15339, 1917], which is also an assertion in tiktoken's own test suite. Turn on the token view above, pick cl100k_base and hover over each highlighted piece of hello world: the tooltips show the same two IDs. For o200k_base the IDs are [24912, 2375].

We tested this page against tiktoken's published cl100k_base test vectors. All matched except one: text containing the control character U+0085 (NEXT LINE) can count one token differently. JavaScript's regular expressions don't treat U+0085 as whitespace and Rust's do, and every JavaScript tokenizer port we checked behaves the same way. Ordinary text never contains this character.

Frequently asked questions

Is my text sent to a server?
No. The tokenizer runs in a Web Worker inside your browser tab. The page downloads two encoding files from larely.com the first time you count something, and after that it makes no network requests at all, so you can disconnect and keep counting. Your text is never transmitted or stored.
Why do GPT-4o and GPT-4 give different counts for the same text?
They use different encodings. GPT-4o, GPT-4.1, GPT-5 and the o-series use o200k_base, a vocabulary of about 200,000 tokens. GPT-4 and GPT-3.5 Turbo use cl100k_base, about 100,000 tokens. English prose usually counts about the same in both, but o200k_base needs noticeably fewer tokens for many other languages and for emoji, because more of those pieces have their own vocabulary entry.
Can this count tokens for Claude or Gemini?
Not exactly. Anthropic and Google do not publish the tokenizers their current models use, so no browser tool can reproduce their counts. The page shows each vendor's own published rule of thumb, clearly labelled as an estimate. For an exact number, call Anthropic's free count_tokens endpoint or Google's countTokens method with the model you plan to use.
Does the count include the system prompt and chat formatting?
It counts exactly the text you paste. A chat request adds a few formatting tokens around every message, and tool definitions and images cost extra. OpenAI's own token-counting example treats those additions as model-specific estimates, so paste your system prompt and messages together and allow a small margin.
Why do emoji and non-English text use more tokens?
These encodings work on UTF-8 bytes. Common English words are single vocabulary entries, while a character outside the most frequent sequences may take two or three byte-level tokens. In cl100k_base the thumbs-up emoji is 3 tokens; in o200k_base it is 1. Turn on the token view above to see exactly where your text is split.

Sources

⚡ LLM Token Counter — by larely ↗

The rest of the workbench

Password Generator

Generate strong, random passwords and passphrases privately in your browser.

Base64 Encoder / Decoder

Encode and decode Base64 text in your browser.

UUID Generator

Generate random version-4 UUIDs, one or in bulk, in your browser.

Text Diff Checker

Compare two texts and highlight the differences line by line.

Hash Generator

Generate SHA-256, SHA-1, SHA-384 and SHA-512 hashes in your browser.

JSON to CSV Converter

Convert a JSON array to CSV and CSV back to JSON.

Image to Base64 Converter

Encode an image to a Base64 data URI for HTML or CSS, in your browser.

Image Compressor & Converter

Compress, resize and convert JPEG, PNG and WebP images in your browser — nothing is upl…

File Checksum Calculator

Verify a file's SHA-256, SHA-1, MD5 or CRC32 checksum in your browser — no upload.

AES-256 Text Encryption

Encrypt and decrypt text with password-based AES-256-GCM, entirely client-side.

HMAC Generator & Verifier

Compute and verify HMAC-SHA256 and other HMAC signatures in your browser.

Test Data Generator

Generate fake mock data as CSV or JSON for testing.

More workbench tools →