LLM Token Counter

Count tokens for OpenAI models with real tokenizer encodings, or estimate usage for Claude, Gemini, DeepSeek and other LLMs. Track context-window usage and API costs — directly in your browser.

OpenAI tokenizer đź”’ Text stays in your browser Free & unlimited
Input text 0 chars
Token count Loading tokenizer…
–
Characters (with spaces)
0
Characters (no spaces)
0
Words
0
Lines
0
Tokens
0
API cost calculator Pre-filled from the selected model · editable
Estimated input: $0.0000 Output budget: $0.0000 Total: $0.0000
Loading the OpenAI tokenizer. Exact text-token counts are available for supported OpenAI encodings; other model families use clearly labeled estimates.
Context window usage 0 / 131,072 tokens
0% of context window used
Same text, every model
Input price per 1M tokens · highest & lowest marked
Model Count Tokens As input Input $/1M
Selecting a model auto-fills the cost calculator prices above. The highest and lowest input prices are highlighted; all other figures are edited live.

OpenAI counts use the selected tokenizer encoding. Counts for other model families are estimates, not official tokenizer results. Tokenization runs locally after the tokenizer library loads.

Count and Estimate Tokens for LLM Prompts

Token counts affect context-window limits and API costs. This tool uses browser-based OpenAI tokenizer encodings for supported GPT model families and a clearly labeled estimation method for other providers. Your prompt text is processed locally in your browser.

Exact Tokenization for Supported OpenAI Models

Modern OpenAI models such as GPT-4o and GPT-4.1 use the o200k_base encoding, while GPT-4 legacy models and GPT-3.5 use cl100k_base. The tokenizer splits text into token IDs; the number of IDs is the text token count. This counts text only, not all chat-message, tool, image, audio or other request overhead.

Estimates for Claude, Gemini and Other Models

Tokenizers differ between model providers. When an official tokenizer is not running in this page, the tool estimates token usage from an OpenAI reference encoding and a model-family adjustment factor. These results are approximate and can vary by language, punctuation, code and model version. Do not treat estimates as billing-grade counts.

Understand Context-Window Usage

Select a context-window size to see how much of it the text estimate or count would use. A real request may also include system instructions, message formatting, conversation history, tool definitions, images and generated output, so the text-only result is not the complete request-token total.

Estimate API Costs by Model

Choosing a model pre-fills its published input and output prices, and you can still edit both to match your provider's current rates. The calculator applies the input price to the current text token count and the output price to your expected output-token budget. Pricing changes frequently, so re-check the figures before relying on an estimate.

Private, Browser-Based Processing

The text is tokenized in your browser and is not sent to our server for counting. The tokenizer library is downloaded from a public CDN when the page loads. If the library cannot load, the page falls back to a labeled estimate rather than presenting a false exact count.

Frequently Asked Questions

Is my text uploaded to a server?

No. Text counting runs in your browser. The tokenizer JavaScript is downloaded from a public CDN, but your input text is not sent to that CDN or to our server.

Are all token counts exact?

No. Supported OpenAI text encodings are counted with a tokenizer. Claude, Gemini, DeepSeek and other unsupported model families are shown as estimates unless an official tokenizer or provider counting API is integrated.

Which OpenAI encodings are supported?

Modern GPT models such as GPT-4o and GPT-4.1 use o200k_base. GPT-4 legacy models and GPT-3.5 use cl100k_base. The selected encoding determines the text-token count.

Why can an API request use more tokens than this page shows?

This page counts the text you paste. API requests may add message formatting, system prompts, conversation history, tool definitions, image or audio content, and output tokens.

How is the API cost calculated?

Each model pre-fills its published input and output prices per one million tokens, and both are editable. The calculator estimates input cost from the current text count and output cost from your expected output-token budget.

Is the tool free?

Yes. The token counter is free to use and requires no registration or installation.