LLM Token Counter for JSON
See how many tokens your data costs in a prompt, and which format is cheapest. Counts use the real o200k tokenizer (GPT-4o, GPT-5 family), loaded locally in your browser.
Token comparison
| Format | Characters | Tokens | vs pretty JSON | Cost |
|---|
Counts use the o200k_base tokenizer from GPT-4o and the GPT-5 family. Claude and Gemini use their own tokenizers, so their counts differ; the relative savings between formats are usually similar. For an exact Claude count, call the Messages API count_tokens endpoint.
How it works
- Paste your dataAny valid JSON: an API response, rows from a database, or retrieved documents for RAG.
- Convert five waysThe data is serialized as pretty JSON, minified JSON, YAML, CSV (for flat lists of records) and TOON.
- Count exactlyEach version is tokenized with the real o200k tokenizer, running locally in your browser.
- Pick the cheapestThe table shows tokens, savings and cost at your price. Click a row to copy that version.
Why format changes the token count
A tokenizer splits text into pieces the model reads. Pretty-printed JSON spends tokens on indentation and line breaks, and every JSON object repeats its keys and quotes. For a list of 100 records with the same fields, the field names alone appear 100 times. Minifying removes the whitespace. Tabular formats go further: CSV and TOON write each field name once in a header, then one compact row per record, which is often 30 to 60 percent fewer tokens for uniform data.
Fewer tokens is not automatically better. Models read JSON very reliably, and deeply nested or irregular data can come out larger, or harder for the model to follow, in a tabular format. Use the cheapest format that keeps the structure the task needs, and test answer quality on a few real prompts before switching a production pipeline.
Estimating cost
Cost is tokens ร requests ร the input price you enter, divided by one million. Input prices are set per model by each provider, so enter the rate for the model you use. If the same data is sent on every request, prompt caching (offered by Anthropic, OpenAI and Google) can cut the cost of those repeated tokens substantially.
Frequently asked questions
Are these token counts exact?
For OpenAI models that use o200k_base (GPT-4o, GPT-4.1, o-series and the GPT-5 family), yes: the tokenizer is the same one those models use. Other providers' tokenizers differ. If the tokenizer file cannot load, the page falls back to an estimate and labels it as one.
Why is CSV missing for my data?
CSV only fits a list of records. It is offered when the top level of your JSON is an array of objects. Nested objects are flattened into dotted column names and nested arrays are written as JSON text inside the cell.
What is TOON?
Token-Oriented Object Notation is a compact, human-readable encoding of JSON designed for LLM prompts. It declares the fields of a uniform array once and lists values row by row, while still supporting nested objects. Our JSON to TOON converter converts in both directions.
Is my data uploaded?
No. Conversion and tokenization both happen in your browser. The tokenizer is a static file served from this site, and your data never leaves the page.