AI token and context budget calculator
Count text in your browser with o200k_base or cl100k_base, then compare it with a context limit, output reserve, and safety buffer you enter.
Your input is not stored or sent. Shared results contain only a summary. Token counts are a plain-text estimate for the selected encoding, not total API usage.
Result
Results appear here after execution.
View the original report·copy directly
Share result
Share the tool link and result text together. No URL is included in the result. Check the below content and then share it.
Usage examples and processing criteria
Count the sample with o200k_base. With a 32,000-token context limit, 2,048 tokens reserved for output, and a 512-token safety buffer, the remaining input budget is 32,000 minus those three amounts. An API request may use more tokens for message formatting, images, files, tool definitions, and other overhead.
Frequently asked questions
Which tokenizer does this use?
It counts the plain text you enter using OpenAI’s o200k_base or cl100k_base encoding. Choosing an encoding does not provide an exact count for a particular model’s full API request.
Does this show exact API usage or the model’s remaining context?
No. You enter the context limit and output reserve yourself. The count excludes system and developer message formatting, tool definitions, images, files, service-added tokens, and model-specific limits, so it does not replace usage information returned by an API.
Is my input sent to a server or stored?
No. The tokenizer runs in a separate browser worker using files bundled with the page. Input is not stored or added to URLs, analytics events, or server requests. Shared results contain only a token-count summary.
Calculation criteria and reference materials
- OpenAI developer documentation — Counting tokens
API requests can include message formatting, images, files, tool definitions, and more in addition to plain text. A local text count cannot provide the total request token count.
- OpenAI — tiktoken encodings
Implementation and descriptions of OpenAI token encodings including o200k_base and cl100k_base. This tool counts plain text only with these two encodings.
- js-tiktoken — JavaScript tokenizer under the MIT License
An MIT-licensed JavaScript port used to count text tokens in the selected encoding in the browser. It does not call a network API.
Verification of calculation criteria: · Calculation·verification principles · Report errors