Skip to content
FreeAIDevTools

OpenAI Token Counter

Exact counts for GPT models, run in your browser with OpenAI's own tokenizer.

How do you count OpenAI tokens? Paste your text into the counter. It runs OpenAI's o200k_base tokenizer in your browser, the encoding GPT-5, GPT-4.1, GPT-4o and o3 bill with, so the number matches the API. OpenAI's rule of thumb is about 4 characters or 0.75 words per token in English. GPT-6 has no published tokenizer, so its counts assume o200k_base.

Paste a prompt, document or code to count its tokens. Counts update as you type, and nothing leaves your browser.
0 characters0 words~0 tokens
Compare models:

$2 input · $10 output per 1M tokens

Input tokens (est.)
0 · $0.00000
Output cost
$0.0050
Cost per call
$0.0050
Per day$5.00
Per month (30 days)$150.00

Same text on other models

Runs in your browser. OpenAI models show exact counts from the official tiktoken tokenizer (o200k_base). Other providers are estimates from characters-per-token ratios, so treat them as a guide; for exact counts use Anthropic's count_tokens endpoint or Gemini's countTokens method. Each card compares your text with the model's context window and flags it once text plus output tokens no longer fit. Prices shown are standard rates; some models charge more for very long prompts (for example OpenAI GPT-5.5 and later above 272K input tokens, xAI above 200K, Claude Haiku 5.5 above 100K).

Open the full Token Counter →

The Inference Report · Every Tuesday

Know when AI prices change.

One short email every Tuesday: new models, price moves and free tiers that were cut or added. Five minutes, no fluff.

No spam. Unsubscribe anytime.

Why are OpenAI counts exact here?

OpenAI publishes its tokenizer as the open source tiktoken library, and a JavaScript port of it runs on this page. Your text is split into tokens on your own machine, with nothing uploaded, which is the same split OpenAI's servers make when they bill you. That is the difference from the estimates on the Claude token counter and the Gemini token counter: those providers do not ship a tokenizer you can run locally.

The one gap is GPT-6. OpenAI has not published which encoding the GPT-6 models use, and the tiktoken library has no GPT-6 entry yet. We assume o200k_base, as for GPT-5. If you need certainty for a GPT-6 bill, compare our count with the usage field in one real API response.

What does a token count leave out?

The counter measures the text you paste. A real request bills more input than that: the system prompt, every earlier turn of the conversation you resend, and any tool definitions all count as input tokens. Paste the whole request body, not only the user message, when you are sizing a production call.

Output is billed separately and costs more. GPT-6.1 Sol charges $2 per 1M input tokens and $10 per 1M output tokens, so set the expected reply length in the counter as well. On reasoning models, the hidden reasoning tokens are billed as output too.

What does OpenAI's context_length_exceeded error mean?

OpenAI's Agents API error guide lists context_length_exceeded with the cause "Input exceeds the model's context window." That window is 1,050,000 tokens on GPT-6.1 Sol, GPT-6.1 Terra and GPT-6 Luna; 400,000 on GPT-5.4 Mini. The counter runs OpenAI's tokenizer, so each card shows the share of the window your text takes and, when over, how much to cut.

The window has to hold the answer as well. OpenAI's docs say the prompt and the generated output combined must be no more than the model's maximum context length, and reasoning tokens count toward the same window. Tokens generated past the limit may be cut off in the response, so a prompt that only just fits leaves no room for a reply. Set the output tokens to the longest answer you expect, and a card flags the model once text plus reply no longer fit.

To fix it, send fewer input tokens. OpenAI's own advice is to reduce the input and, when a conversation has grown too long, to start a new session with a shorter summary. The Responses API can also compact a long conversation on the server when you set context_management with a compact_threshold. Or switch to a model with a bigger window; you can compare models side by side, context sizes included. GPT-6 counts here assume o200k_base, so when a GPT-6 prompt is close to the limit, confirm with the usage field of a real response.

What does a 2,000-word document cost on OpenAI?

At OpenAI's 0.75 words per token, 2,000 words of English is about 2,667 tokens. As input, that costs $0.00533 on GPT-6.1 Sol and $0.00027 on GPT-6 Luna. Small numbers per call, but a pipeline that sends the same document 10,000 times a day turns them into a real line item. Every current model's rate is in our OpenAI API prices table, and the LLM cost calculator projects a monthly bill. Batch, cache-write and long-prompt rules are on the OpenAI API pricing page.

Frequently asked

Does OpenAI use the same tokenizer for GPT-6?

OpenAI has not said. The tiktoken library maps GPT-5 models to o200k_base and has no GPT-6 entry yet, so this counter assumes o200k_base for GPT-6 as well. The usage field in an API response gives the billed number if you need to confirm it.

How many tokens is 1,000 words for OpenAI models?

About 1,333, using OpenAI's rule of thumb of 0.75 words per token for English text. When we measured how many tokens a word is on o200k_base, English prose came to 1,318 to 1,390 tokens per 1,000 words. Code, numbers, URLs and most other languages produce more tokens per word, so paste a real sample for the exact figure.

Is the OpenAI API free to use for counting tokens?

You do not need the API at all to count tokens: the tokenizer here runs offline in your browser and costs nothing. To call GPT models you need prepaid credit; see is the OpenAI API free for what new accounts get.

How do you fix context_length_exceeded in the OpenAI API?

Send less input. Paste the full request, including the system prompt and the earlier turns you resend, into the counter to see how far over the model's window it is, then trim or summarize until the card stops flagging it. For long chats, OpenAI suggests a new session that starts from a shorter summary, or you can turn on server-side compaction in the Responses API.

More in this series