OpenAI tokenizer

OpenAI Token Calculator

Count prompt tokens with OpenAI tiktoken-compatible encodings and estimate input, output, per-request, and monthly API cost.

Count OpenAI tokens with tiktoken encodings

Uses bundled tiktoken-compatible BPE ranks in the browser. Your text is not sent to a server.
Input tokens0
Input cost per request$0.00
Total cost per request$0.00
Monthly tokens0
Estimated monthly cost$0.00
Words0
Characters0
Chars per token0
Token IDs preview[]
Important: this counts raw text tokens for the selected encoding. Chat messages, tool calls, structured outputs, and API wrappers may add extra tokens.
tiktoken

Use OpenAI-style encodings

Switch between o200k_base and cl100k_base for modern OpenAI text workloads.

Cost

Estimate API spend

Combine counted input tokens with expected output length and request volume.

Private

Runs in the browser

The tokenizer and cost math run locally in your browser. The page does not upload prompt text.

When to use this OpenAI token calculator

Use this page when you need OpenAI-oriented token counts for prompts, document chunks, system messages, examples, or other raw text before estimating API spend.

The cost estimate uses input tokens * input price + expected output tokens * output price, then multiplies that request cost by monthly request volume.

NeedRecommended pageReason
OpenAI API costOpenAI API Cost CalculatorUses counted or estimated tokens to model production API spend.
OpenAI token countingOpenAI Token CalculatorUses tiktoken-compatible encodings for raw text.
Cross-provider estimateToken CounterWorks across OpenAI, Claude, and Gemini-style planning.
Monthly LLM budgetLLM Cost CalculatorModels users, request volume, input tokens, output tokens, and cached input.

FAQ

Is this the same as the OpenAI API usage number?

Not always. The raw text token count should match the selected encoding for text, but API usage can include chat formatting, tool call, or response-format overhead.

Which encoding should I choose?

Use o200k_base for newer OpenAI-style workloads and cl100k_base when comparing against older GPT-4/GPT-3.5-era examples.

References

Pricing data was last checked on 2026-07-02. Verify pricing and tokenizer behavior against official OpenAI sources before final budgeting.