OpenAI Tokenizer Online

Count plain-text tokens with current or legacy OpenAI encodings, then inspect each token boundary and ID in your browser.

Ready
0tokens
0characters
0words
Tokenized text will appear here as you type.

Your text stays in this browser. Nothing you paste is uploaded.

How counting works

This page runs the selected OpenAI text encoding locally in your browser and returns its token boundaries and token IDs.

Only the text you enter is encoded. API message formatting, tools, images, and other request fields can add tokens.

For request-volume and output-token calculations, see the monthly LLM API cost guide. Using OpenAI? Check the current OpenAI API token prices.

To compare the same English, Chinese, JSON, and code samples, open the reproducible tokenizer comparison.

View tokenizer source
How StackLens verifies data and calculates cost

OpenAI TokenizerHigh confidenceChecked 2026-07-19

StackLens runs matching OpenAI text encodings locally through js-tiktoken. API message formatting and non-text request fields are outside this plain-text count.

FAQ

OpenAI Tokenizer questions

Does this OpenAI tokenizer run online?

The page is delivered online, but tokenization runs locally in your browser. StackLens does not upload the text you enter.

Can I view OpenAI token IDs?

Yes. The Text and Token IDs views show the pieces and numeric IDs produced by the selected OpenAI encoding.

Why can OpenAI API usage differ from this count?

This tool encodes only the text you paste. API messages, roles, tools, images, and other request fields can add tokens.

What is the difference between Current and Legacy?

They select different OpenAI text encodings. The same text can produce different boundaries and IDs, so use the encoding that matches the model family you are evaluating.