How to count Claude tokens

Step-by-step guide for developers using the Messages API.

  1. 1

    Copy your user message (and optional system prompt) into the tokenizer.

  2. 2

    Select the exact model ID you will call in production.

  3. 3

    Click Count tokens and note input_tokens.

  4. 4

    Add tool definitions, images, or PDFs in your real API call — they add tokens not shown in plain text alone.

  5. 5

    Leave headroom below the model context window for the model's reply.

Open token counter