LLM Token Counter for Structured Data
See what your JSON costs in tokens, and which format is cheapest.
LLM APIs bill and limit by tokens, not characters, and structured data is expensive: every quote, brace and repeated key is tokenised. This counter tokenises your document and shows the count for the same data written as pretty JSON, minified JSON, YAML, CSV and TOON.
Counts use the o200k_base encoding from the GPT-4o model family and are computed in your browser. Other providers tokenise differently, so treat the numbers as a close estimate for them; the ranking between formats is usually the same.
How to use it
- Paste the data you plan to include in a prompt.
- Compare the token counts per format in the side panel.
- Pick a cheaper format in the Convert to menu and copy the result.
Questions
Which tokenizer is used?
o200k_base, the encoding used by the GPT-4o model family. The tokenizer is downloaded once and runs entirely in your browser.
Are the counts accurate for Claude or Gemini?
They are an approximation. Those models use their own tokenizers, so absolute numbers differ, but the relative difference between formats is a reliable guide.
What is the quickest way to reduce tokens?
Minify JSON to drop whitespace, remove fields the model does not need, and use CSV or TOON for arrays of uniform records.
All tools
- JSON Formatter
- JSON Validator
- JSON Minifier
- JSON Repair
- JSON Diff
- JSON Schema Validator
- JSON to YAML
- YAML to JSON
- JSON to CSV
- CSV to JSON
- JSON to XML
- XML to JSON
- YAML Formatter
- XML Formatter
- JSONL Validator
- JSON to TOON
- LLM Token Counter
- LLM Token Optimizer
- JSON to TypeScript
- JSON Schema Generator
- LLM Tool Schema Generator