Token Studio

OpenAI Token Counter

Count tokens and estimate cost for GPT-5, GPT-4.1, GPT-4o, and GPT-4 Turbo. OpenAI's real encodings run in your browser. Nothing is uploaded.

Runs entirely in your browser Nothing is uploaded
Loading tokenizer…
6.4 MB · one-time
Est. cost
 
Tokens / word
 
Chars / token
 
Characters
327
58 words
Context window
Input text
327characters
270no spaces
58words
4sentences
Token breakdown
GPT-5 · o200k_base
Loading GPT tokenizer · 6.4 MB
Compare models — same text 4 of 28 · click to inspect
Model Tokens Cost
GPT-5
loading tokenizer…
—
GPT-4.1
loading tokenizer…
—
GPT-4o
loading tokenizer…
—
GPT-4 Turbo
loading tokenizer…
—

Counts come from each model's real tokenizer, running entirely in your browser. Cost and context-window figures are estimates for guidance and may vary by model version.

Counting tokens for OpenAI models

This page runs OpenAI's own tiktoken vocabularies, so the counts match what the API measures. Type or paste your text above and the count updates as you go, along with the cost of sending it as input and how much of the model's context window it fills. GPT-5, GPT-4.1, GPT-4o, and GPT-4 Turbo load by default; add GPT-4o mini, GPT-3.5 Turbo, or GPT-OSS from the compare table to price the same text across the rest of the lineup.

Pricing and context windows

Every OpenAI model in the tool, with the encoding it uses, its input price, and its context window.

ModelTokenizerPrice / 1M inputContext window
GPT-5o200k_base$1.25400K
GPT-4oo200k_base$2.50128K
GPT-4o minio200k_base$0.15128K
GPT-4.1o200k_base$2.001M
GPT-4 Turbocl100k_base$10.00128K
GPT-3.5 Turbocl100k_base$0.5016K
GPT-OSSo200k_harmonyFree131K

Prices and context windows are curated metadata refreshed periodically from the providers and OpenRouter, so treat them as guidance rather than a quote. Token counts are always produced by the real tokenizer.

How OpenAI tokenization works

Current OpenAI models share one encoding, o200k_base; older ones share cl100k_base. GPT-5, GPT-4.1, GPT-4o, and GPT-4o mini all tokenize with o200k_base, a vocabulary of about 200,000 entries, so the same text produces the same count on all four and only the price differs. GPT-4 Turbo and GPT-3.5 Turbo use the older cl100k_base, which splits text slightly differently. GPT-OSS, the open-weight release, uses o200k_harmony, an extension of o200k_base with tokens reserved for its response format.

All three encodings run here as the real vocabularies converted from tiktoken, not an approximation, so the numbers match what OpenAI's own library reports for the same text.

Frequently asked questions

How do I count tokens for GPT-5?

Paste your text with GPT-5 selected: it runs o200k_base, the encoding GPT-5 uses. The vocabulary is downloaded once and the text is tokenized in your browser, so nothing is uploaded. In code, OpenAI's open source tiktoken library returns the same count with the o200k_base encoding.

Is the ChatGPT token count the same as the API?

The text itself tokenizes identically, but a ChatGPT request bills more than the text you see. Each turn also carries the system prompt, the earlier messages in the conversation, and a few tokens of per-message formatting. Use this counter for the text, then add headroom for the rest when you budget an API call.

Which GPT models share a tokenizer?

GPT-5, GPT-4.1, GPT-4o, and GPT-4o mini share o200k_base; GPT-4 Turbo and GPT-3.5 Turbo share cl100k_base. Models inside a group always return the same count for the same text, which is why the compare table shows identical numbers at different prices. GPT-OSS is the exception: it uses o200k_harmony, a superset of o200k_base.

Does this include system prompts or images?

No. It counts exactly the text in the box. System prompts, tool definitions, and prior messages all add input tokens to a real request, and images are charged with their own tile-based formula. Count those parts separately and add them to the figure here.