---
title: "Count a page's tokens with the model you will use: Agent Ready HTML"
description: "How many tokens is a web page? See why the count depends on the model's tokenizer, and how to measure the HTML and markdown versions with that model."
canonical: https://agentreadyhtml.com/guides/how-many-tokens-does-a-page-cost/
site: "Agent Ready HTML"
last_updated: 2026-11-18
date: 2026-11-18
section: "Guides"
---

# Count a page's tokens with the model you will use: Agent Ready HTML

> How many tokens is a web page? See why the count depends on the model's tokenizer, and how to measure the HTML and markdown versions with that model.

Source: https://agentreadyhtml.com/guides/how-many-tokens-does-a-page-cost/
Site: Agent Ready HTML
Last reviewed: 2026-11-18

# Count a page's tokens with the model you will use

In short

Token counts depend on the tokenizer of the model you count with. Save the HTML as served and its markdown version, send each alone through the counting call of the model you will use, and write the model ID beside both figures.

Published 18 November 2026

Cloudflare's [launch post](https://blog.cloudflare.com/markdown-for-agents/) reports one example: the post itself takes 16,180 tokens in HTML and 3,150 tokens converted to markdown, which Cloudflare calls an 80% reduction in token usage. Its converted responses carry x-markdown-tokens, a header with the estimated token count of the markdown body, and the post suggests using that value to calculate the size of a context window or to decide on a chunking strategy.

Related: [x-markdown-tokens](https://agentreadyhtml.com/glossary/x-markdown-tokens/)

Token estimates in Cloudflare's conversion analytics use bytes divided by four, rounded down, rather than a tokenizer, according to the [Markdown for Agents docs](https://developers.cloudflare.com/fundamentals/reference/markdown-for-agents/).

Related: [Token reduction](https://agentreadyhtml.com/glossary/token-reduction/)

## Capture the HTML and its markdown version

Start with two captures of the same URL: the HTML exactly as the server returns it, and its markdown version. The [llms.txt proposal](https://llmstxt.org/) puts that markdown version at the same URL as the original page, with .md appended (page.html.md) or with the extension replaced by .md (page.md).

Related: [How to serve markdown on request on each host](https://agentreadyhtml.com/guides/serve-markdown-on-request/)

On a zone with Cloudflare's Markdown for Agents enabled, the client asks for markdown by adding the Accept header with text/markdown as one of the options, as in [Cloudflare's example request](https://developers.cloudflare.com/fundamentals/reference/markdown-for-agents/):

curl https://developers.cloudflare.com/fundamentals/reference/markdown-for-agents/ \\
  -H "Accept: text/markdown"

Cloudflare fetches the original HTML from the origin and converts it before serving it. Headers, footers, navigation, scripts and styles are stripped during pre-processing. Any JSON-LD survives as a fenced json code block at the end of the document, and YAML frontmatter with metadata from the page's meta tags may open it.

Related: [Markdown negotiation by platform](https://agentreadyhtml.com/markdown-negotiation-by-platform/)

## Claude counts under the model ID you pass

Anthropic's endpoint accepts the same structured list of inputs used to create a message and returns input\_tokens, as in [Anthropic's Python example](https://platform.claude.com/docs/en/build-with-claude/token-counting):

```python
client = anthropic.Anthropic()
response = client.messages.count_tokens(
    model="claude-opus-5-5",
    messages=[{"role": "user", "content": "Hello, Claude"}],
)
print(response.json())
```

Put the saved HTML in the content string for one count and the saved markdown for the other. The endpoint counts under the tokenizer of the model you pass. Claude 4.7 and later models and Claude Mythos Preview use a newer tokenizer, and on them the same input text produces approximately 30 percent more tokens than on earlier models; the exact increase depends on the content and workload shape. Anthropic's guidance is to count with the model ID you plan to use and not to reuse counts measured on an older model.

[Anthropic's token counting page](https://platform.claude.com/docs/en/build-with-claude/token-counting) calls the returned count an estimate. In some cases the input tokens used when you create the message might differ by a small amount. Counting is free to use, subject to per-minute rate limits.

## OpenAI counts the request, tiktoken counts plain text

OpenAI's input token count endpoint accepts the same input format as the Responses API and, in the words of [OpenAI's counting guide](https://developers.openai.com/api/docs/guides/token-counting), returns the exact count the model will receive:

```python
from openai import OpenAI
client = OpenAI()
response = client.responses.input_tokens.count(
    model="gpt-6.2-astra",
    input="Tell me a joke."
)
print(response.input_tokens)
```

That figure includes formatting tokens that represent request structure, such as message roles and boundaries, and those might not appear in text you tokenize locally. Local tokenizers such as tiktoken work for plain text, but images and files are not supported, and the guide calls estimates like characters / 4 inaccurate. Tools and schemas also add tokens that are hard to count locally.

For page text on your own machine, OpenAI publishes [tiktoken](https://github.com/openai/tiktoken), a fast BPE tokeniser for use with its models. Load an encoding by name, such as o200k\_base, or let encoding\_for\_model("gpt-4o") pick the tokeniser for a specific model in the OpenAI API, then pass text to enc.encode to get its tokens. On average, in practice, each token corresponds to about 4 bytes.

## Gemini counts the input only

Calling count\_tokens with the input of a request returns the total number of tokens in the input only. Google says to make this call before sending input to check the size of your requests. [Gemini's tokens page](https://ai.google.dev/gemini-api/docs/tokens.md.txt) also gives a rule of thumb for Gemini models: a token is about 4 characters, and 100 tokens is about 60-80 English words.

## Keep request overhead out of the page figure

Anthropic's input\_tokens is the [total across the messages](https://platform.claude.com/docs/en/build-with-claude/token-counting), system prompt, and tools you provide, and it might include tokens Anthropic adds automatically for system optimizations, which are not billed. OpenAI's count carries [formatting tokens](https://developers.openai.com/api/docs/guides/token-counting) for roles and boundaries.

Send each version of the page as the only message content, with no system prompt and no tools attached. Keep every other part of the two requests identical.

## Images you send with the page

Claude reads an image in 28×28-pixel patches called visual tokens, so one image costs ceil(width / 28) × ceil(height / 28) visual tokens, per [Anthropic's vision page](https://platform.claude.com/docs/en/build-with-claude/vision). Each model also has a long-edge limit and a visual-token limit. Claude 4.7 and later models sit in the high-resolution tier at 2,576 px and 4,784 visual tokens; all other models sit in the standard tier at 1,568 px and 1,568 visual tokens. An image over either limit is downscaled to the largest size that fits the tier while preserving its aspect ratio, which caps the token cost. A 1000x1000 px image is not resized on either tier and costs 1,296 tokens.

Gemini counts an image no larger than 384 pixels in both dimensions as 258 tokens, and tiles a larger image into 768x768 pixel tiles that count as 258 tokens each ([Gemini's image rule](https://ai.google.dev/gemini-api/docs/tokens.md.txt)).

## Record each count with its model

To compare two tokenizers, Anthropic says to count the same request once with the current model and once with the model you plan to move to, then compare the two input\_tokens values ([Anthropic's migration advice](https://platform.claude.com/docs/en/build-with-claude/token-counting)). Write the model ID next to every HTML and markdown figure you keep, and compare a pair only when both numbers came from the same model.

## Sources

1.  [Anthropic: Token counting](https://platform.claude.com/docs/en/build-with-claude/token-counting) https://platform.claude.com/docs/en/build-with-claude/token-counting, read 18 November 2026
2.  [OpenAI: Counting tokens](https://developers.openai.com/api/docs/guides/token-counting) https://developers.openai.com/api/docs/guides/token-counting, read 18 November 2026
3.  [OpenAI (GitHub): tiktoken](https://github.com/openai/tiktoken) https://github.com/openai/tiktoken, read 18 November 2026
4.  [Google: Understand and count tokens (Gemini API, markdown version)](https://ai.google.dev/gemini-api/docs/tokens.md.txt) https://ai.google.dev/gemini-api/docs/tokens.md.txt, read 18 November 2026
5.  [Cloudflare: Introducing Markdown for Agents](https://blog.cloudflare.com/markdown-for-agents/) https://blog.cloudflare.com/markdown-for-agents/, read 18 November 2026
6.  [Cloudflare: Markdown for Agents](https://developers.cloudflare.com/fundamentals/reference/markdown-for-agents/) https://developers.cloudflare.com/fundamentals/reference/markdown-for-agents/, read 18 November 2026
7.  [Anthropic: Vision](https://platform.claude.com/docs/en/build-with-claude/vision) https://platform.claude.com/docs/en/build-with-claude/vision, read 18 November 2026
8.  [llmstxt.org: The /llms.txt file](https://llmstxt.org/) https://llmstxt.org/, read 18 November 2026

Last reviewed 18 November 2026

Edition

Crawl

2026-11-04

Page updated

2026-11-18

Method

How the viewer reads a page, how a file is graded and how a platform is scored: [the method page](https://agentreadyhtml.com/method/).
