---
title: "AI Token Counter | ToolSugar"
description: "Count tokens in a prompt with OpenAI's cl100k_base or o200k_base encodings. An estimate for other vendors. Runs in your browser."
canonical: https://toolsugar.com/tools/token-counter
image: https://toolsugar.com/og.png
---

# AI Token Counter

This token counter counts how many tokens your text uses with OpenAI's cl100k_base (GPT-4, GPT-3.5) or o200k_base (GPT-4o) encodings, plus characters and words. The count is exact for those OpenAI encodings and only an estimate for other vendors' models, which tokenize differently. It runs in your browser.

Runs on your device

## How it works

1. Paste or type your prompt into the box.
2. Choose cl100k_base or o200k_base to match the model family.
3. Read the token, character and word counts, which update as you type.
4. Compare the token count with the model's context limit.

## Key facts

- **Encodings**: cl100k_base and o200k_base
- **Accuracy**: Exact for OpenAI models using that encoding; an estimate for Claude, Gemini, Llama and others
- **Loading**: The tokenizer data downloads the first time you use an encoding
- **Where it runs**: In your browser, with no upload of your text

## Common uses

- Check that a prompt fits in a model's context window.
- Estimate API cost before sending a long document.
- Compare how two phrasings differ in token use.

## Questions

### Is the token count exact for Claude or Gemini?

No. This tool uses OpenAI encodings, so for other vendors' models it is only an estimate. Their own tokenizers can give noticeably different counts.

### Which encoding should I pick?

Use cl100k_base for GPT-4 and GPT-3.5 style models and o200k_base for GPT-4o style models. Counts for the same text can differ between them.

### Why does the first count take a moment?

The tokenizer vocabulary is a large file that loads when you first need it. After that, counting is instant and the text still stays on your device.

[Read the AI Token Counter guide](https://toolsugar.com/blog/how-to-count-tokens-for-ai-models)

## Related tools

- [Diff Checker](https://toolsugar.com/tools/diff-checker)
- [Base64 Encoder and Decoder](https://toolsugar.com/tools/base64-encoder)
- [Password Generator](https://toolsugar.com/tools/password-generator)
