AI EngineerGuide

OpenAI token counter

Exact OpenAI token counts for GPT-5, GPT-4o, GPT-4.1 and o-series models, with a token-by-token view.

Runs in your browser. Nothing you paste is uploaded.

Or drop a .txt, .md or .json file here, or . It's read in your browser.

299 characters Β· 53 words

Token counts by tokenizer
TokenizerTokensTypeUsed by
OpenAI o200k_base73exact Exact (gpt-tokenizer 4.1.0)GPT-4o, GPT-4.1, GPT-5.x, GPT-6, o-series
OpenAI cl100k_base75exact Exact (gpt-tokenizer 4.1.0)GPT-4, GPT-4 Turbo, GPT-3.5 Turbo, text-embedding-3
Claude 4.7 and later112estimate characters Γ· 3.5 Γ— 1.3Opus 4.7+, Sonnet 5.x, Haiku 5.5, Fable, Mythos
Claude before 4.786estimate characters Γ· 3.5Sonnet 4.5/4.6, Haiku 4.5, Opus 4.6 and earlier
Gemini75estimate characters Γ· 4Gemini API models

Pick a model to see what these tokens cost as input or output, and how much of its context window they use.

View OpenAI tokens

Each colored block is one token. Only the first 2,000 tokens are shown.

The OpenAI counts for the sample text are already filled in. The two OpenAI tokenizer files (about 1.5 MB compressed) load the first time you edit the text.

How to use it

  1. Paste your prompt or drop a text file.
  2. Use the o200k_base row for GPT-4o and newer models, and cl100k_base for GPT-4, GPT-4 Turbo and GPT-3.5 Turbo.
  3. Open View OpenAI tokens to see exactly how your text is split.

How we count OpenAI tokens

Counts are exact for the text you paste. They’re computed in your browser with gpt-tokenizer 4.1.0 (MIT), using OpenAI’s o200k_base and cl100k_base encodings. We check it against tiktoken’s test vectors, for example hello world encodes to [24912, 2375] in o200k_base (checked 2026-11-02).

A Chat Completions or Responses request adds a few tokens per message for roles and formatting, and tool definitions are counted too, so your billed input will be slightly higher than the count here.

FAQ

Is this the same as OpenAI's tiktoken?

Yes, for the text itself. It uses the o200k_base and cl100k_base encodings through gpt-tokenizer, which matches tiktoken’s output. Chat requests add a few tokens per message for formatting, which this counter doesn’t include.

Which encoding does GPT-5 use?

GPT-4o, GPT-4.1, the GPT-5 family and later models, and o-series reasoning models use o200k_base.

Do reasoning tokens count toward my bill?

Yes. Reasoning models bill hidden reasoning tokens as output tokens. This counter measures the text you send, so budget extra output for reasoning.

Is my text sent to OpenAI?

No. Tokenization runs in your browser and nothing is uploaded.