Gemini Tokenizer

Count text tokens, inspect token boundaries and IDs, and keep your prompt in the browser.

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

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

Gemini API token counts may differ for structured messages, system instructions, tools, media, and model-specific processing.

How counting works

This page runs a Gemini-compatible SentencePiece tokenizer locally in a Web Worker. Token IDs and boundaries come from the tokenizer rather than from splitting text on spaces.

Only plain text is encoded. The tool does not add chat templates, roles, system instructions, tools, or media tokens, so API usage can differ.

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

FAQ

Gemini tokenizer questions

What does the Gemini tokenizer show?

It shows the total token count, token boundaries, token IDs, characters, and words for the plain text you enter.

Is this an official Google Gemini tool?

No. StackLens provides a local Gemini-compatible tokenizer for inspecting plain text. It does not call the Gemini API or represent an official Google interface.

Will the Gemini API return the same token count?

Not always. Structured messages, system instructions, tools, files, images, audio, video, and model-specific processing can add or change tokens in an API request.

Are these official Gemini API token IDs?

No. The displayed IDs belong to the local tokenizer used by this page and should not be treated as official IDs returned by the Gemini API.

Does my prompt leave the browser?

No. Tokenization runs locally in your browser, and StackLens does not upload the text you enter.

Does this count images, audio, video, or tool definitions?

No. This page is for plain text. Use the Gemini API token-counting method when you need provider-side counts for structured or multimodal requests.