How to count tokens in a prompt
- Paste the exact text you plan to use, including line breaks, code indentation or JSON punctuation.
- Select the encoding used by your model. Enable comparison to see how both encodings split the same text.
- Enter a budget to see how many tokens are left for the selected encoding. Allow separately for other parts of your request and the response.
Token counts for English, Chinese and code
Count each example on its own. Combining snippets, changing spaces or adding a line break can change the total.
| Example text | o200k_base |
cl100k_base |
|---|---|---|
Hello, world! |
4 | 4 |
你好,世界! |
4 | 7 |
const answer = 42; |
6 | 6 |
Frequently asked questions
What is the difference between a token and a word?
A token is a piece of text defined by an encoding. It can be a whole word, part of a word, a space or punctuation. A fixed characters-per-token estimate is unreliable across languages, code and emoji.
Which encoding should I select?
Select o200k_base for GPT-5, GPT-4.1 or GPT-4o. Select cl100k_base for GPT-4 or GPT-3.5 Turbo. For other models, check the documented tokenizer.
Why can this differ from API usage?
This tool counts the plain text in the box. A full request may include message structure, tool definitions or attachments. Generated responses also use tokens. Use your provider’s request counter or usage report for the full request.
Is my text uploaded, and what is the limit?
The tokenizer loads from this site and processes the text in your browser. The limit is 50,000 Unicode code points. Some visible characters, such as combined emoji, contain more than one code point.