JSON token counter

Input
Output

Token Counter for JSON and Prompts

Language models bill and limit by tokens, not characters, and JSON is expensive: every brace, quote and repeated key costs tokens. Paste a prompt or a payload to see exactly how many tokens it takes for OpenAI models, an estimate for Claude and Gemini, and how many the same data takes minified, as YAML or as a CSV table.

Example: what a list of records costs in tokens

Two orders as an API returns them, indented. The table shows the exact GPT-4o count for the text as typed, and what the same data costs minified, as YAML and as a CSV table:

JSON

[
  {
    "id": "ORD-20419",
    "customer": "Ana Souza",
    "total": 740.5,
    "status": "paid"
  },
  {
    "id": "ORD-20420",
    "customer": "Ravi Kumar",
    "total": 120,
    "status": "pending"
  }
]

Output

Model · Tokens · How counted
OpenAI: GPT-5, GPT-4.1, GPT-4o, o1, o3, o4-mini · 77 · exact, o200k_base
Claude · ≈ 77 · estimate
Gemini · ≈ 77 · estimate
Characters · 208
Bytes (UTF-8) · 208
Words · 19
Lines · 14
Written as · Tokens · Chars · Change
As typed · 77 · 208 · 
Minified · 46 · 147 · -40%
YAML · 51 · 137 · -34%
CSV · 31 · 88 · -60%

How do I use the JSON token counter?

  1. Paste a prompt, a JSON payload or any text.
  2. Pick the encoding: o200k_base for GPT-5, GPT-4.1, GPT-4o and the o-series, cl100k_base for GPT-4 and GPT-3.5 Turbo.
  3. Read the count, and for JSON, how many tokens each other way of writing it saves.

What does the JSON token counter do?

  • Exact OpenAI counts (o200k_base, cl100k_base)
  • Minified, YAML and CSV compared
  • Counted in your browser: your text never leaves it

When to use the JSON token counter

A token is a piece of text a model reads as one unit: a common word, part of a longer word, a space with a word, or a single punctuation mark. Prices, rate limits and context windows are all counted in tokens, so the token count, not the character count, tells you what a request costs and whether it fits. OpenAI publishes its tokenizers, so the count here for GPT models is exact: the same numbers the API reports for the text, before the few tokens each chat message adds.

JSON takes more tokens than its length suggests. Quotes, colons, braces and the same keys repeated in every item each cost tokens, and indentation costs more. Minifying usually saves a large share for nested data, and a list of records written as a CSV table often takes half the tokens or less, because each key is written once, in the header. YAML drops the quotes and braces but keeps the indentation, so it can come out ahead or behind; the table here shows which for your data.

Anthropic and Google don't publish tokenizers that run offline, so Claude and Gemini rows show the OpenAI count as a guide; their own counts differ by model and by text. For an exact Claude or Gemini number, use their token-counting API with the same text.

Frequently asked questions

Which encoding should I pick?
o200k_base for GPT-5, GPT-4.1, GPT-4o and the o-series (o1, o3, o4-mini); cl100k_base for GPT-4, GPT-3.5 Turbo and the text-embedding-3 models. Other languages than English usually take fewer tokens with o200k_base.
Is my text sent anywhere?
No. The tokenizer is a file your browser downloads the first time you use the tool, and the counting happens on your device.
Is my data uploaded?
No. Bracely runs entirely in your browser, so nothing you paste or open leaves your device.

More JSON tools

Bracely has 105 JSON tools in one page. Related ones:

Runs entirely in your browser. Nothing you paste is uploaded. Made by Saurabh Pagrut · About · Privacy policy
Last updated · Version 6.1 · Changelog
Saurabh Pagrut on GitHub · LinkedIn · X · YouTube · Instagram