Skip to main content

Approximate prompt token inspector

AI Token Visualizer

Visualize approximate token-sized text chunks, inspect prompt composition, and estimate context-window usage with reserved output capacity.

Visible token-sized chunksConfigurable character heuristicContext-window capacity check

Prompt text and context assumptions

Inspect transparent character groups, not provider tokenizer output.

Up to 20,000 characters. Text stays in your browser.

tokens
tokens

Approximate token analysis

Character heuristic and context capacity

Fits the selected context window

The approximate prompt and output reserve remain below the selected limit.

Estimated input tokens

20

Projected context use

12.45%

Remaining input capacity

7,172

After reserving output tokens

Unicode characters

80

Words

12

Calculation basis

Characters per token
4
Lines
1
Reserved output
1,000 tokens
Context window
8,192 tokens

Approximate token boundaries

Spaces are shown as ·, line breaks as ↵, and tabs as ⇥.

1Esti2mate3·app4roxi5mate6·tok7en·b8ound9arie10s·be11fore12·sen13ding14·thi15s·pr16ompt17·to·18an·A19I·mo20del.

Letters

68

Digits

0

Whitespace

11

Symbols

1

Formula

How approximate token visualization works

The visualizer groups Unicode characters using a configurable characters-per-token heuristic. It does not reproduce a provider tokenizer.

Estimated input tokens = ceil(Unicode characters ÷ characters per token)

Projected total tokens = estimated input tokens + reserved output tokens

Remaining input capacity = context window − reserved output − estimated input

token-visualizer.ts
export function approximateTokens(
  text: string,
  charactersPerToken = 4,
) {
  const characters = Array.from(text);
  const chunks: string[] = [];

  for (
    let index = 0;
    index < characters.length;
    index += charactersPerToken
  ) {
    chunks.push(
      characters.slice(index, index + charactersPerToken).join(""),
    );
  }

  return {
    estimatedTokens: chunks.length,
    chunks,
  };
}

Example prompt inspection

A four-characters-per-token heuristic is useful for early English-language planning, but code, structured data, emojis, and non-English text can differ significantly.

Use the context controls to reserve room for the model response. For exact billing or hard context limits, run the provider's tokenizer for the exact model and serialized request.

What this estimate includes

  • Unicode character, word, and line counts
  • Approximate token-sized text chunks
  • Letter, digit, whitespace, and symbol composition
  • Projected context usage and remaining input capacity

Frequently asked questions

Are the displayed chunks real model tokens?

No. They are transparent character groups used for planning. Actual token boundaries depend on the model vocabulary, tokenizer version, language, whitespace, and request formatting.

Why use four characters per token?

It is a common rough estimate for English prose. Adjust the input when you have observed tokenizer ratios for your content.

Does the context estimate include the response?

Yes. Reserved output tokens are added to the estimated input tokens so the projected total can be compared with the selected context window.

What else consumes context?

System instructions, tool definitions, message wrappers, retrieved documents, images, hidden provider formatting, and prior conversation turns may consume additional context.