AI JSON Token Counter
Estimate the LLM token count of a JSON payload for context budgeting.
- 100% client-side · your data never leaves your browser
- Instant, no rate limits
- Free, no sign-up
Your result appears here
Paste JSON into the panel on the left — everything runs privately in your browser.
Overview
JSON Token Counter — Estimate LLM Tokens for JSON
Estimate how many tokens a JSON payload will use before you send it to an LLM like ChatGPT, Claude, or Gemini. JsonDrift compares the minified and formatted forms, shows characters and bytes, and tells you how many tokens minifying saves — so you can budget context windows and trim payloads. Everything runs in your browser.
Why count tokens in JSON?
LLMs bill and limit by tokens, and JSON is verbose — braces, quotes, and repeated keys all cost tokens. When you stuff API responses or documents into a prompt, it's easy to blow past the context window or run up cost. A quick estimate tells you whether a payload fits and where the weight is.
How the estimate works
The counter uses the common rule of thumb that one token is roughly four characters for English-and-JSON text, blended with a word-based estimate for a more stable number. It reports tokens for both the minified and formatted versions alongside exact character and byte counts.
Minify to save tokens
Pretty-printed JSON adds indentation and newlines that a model still pays for. The tool shows how many tokens you save by minifying — often 10-30% — which is free budget you can spend on more data or a longer response. For large payloads, also consider removing nulls and empty fields with the JSON Cleaner first.
About accuracy
This is an estimate, not exact tokenizer output. Real tokenizers (OpenAI's tiktoken, Anthropic's tokenizer) split text differently and will vary by roughly 10-20%, especially for non-English text, long numbers, or unusual symbols. Use the estimate to compare payloads and budget context, and verify with the provider's tokenizer when you need an exact count.
FAQ
Frequently asked questions
How many tokens is my JSON?
Paste your JSON and the tool estimates the token count for both minified and formatted forms, along with character and byte sizes.
How accurate is the estimate?
It's a heuristic (about four characters per token) and will differ from a real tokenizer by roughly 10-20%. Use it for budgeting and comparisons, not exact billing.
Does minifying JSON reduce tokens?
Yes. Removing indentation and newlines typically cuts 10-30% of tokens; the tool shows the exact savings for your payload.
Is my JSON uploaded?
No. The estimate is computed locally in your browser, so your data never leaves your machine.
Continue with a related tool
All tools- AI JSON Repair
Fix broken LLM JSON — fences, truncation, unquoted keys, and JS literals. Rule-based today.
- AI JSON Schema Enforcer
Auto-fix JSON to match a schema — coerce types, drop extras, fill required fields.
- AI JSON Cleaner
Smart cleanup — remove nulls, empty strings, trim whitespace, drop empty objects.
- AI JSON Explainer
Human-readable summary of JSON structure and field meanings from naming patterns.
- AI JSON Redactor
Mask passwords, API keys, PII, and secrets before pasting JSON into an LLM.
- JWT Decoder
Decode JWT header and payload — inspect claims without verifying signatures.