TokenPad
Format

JSON Validator with Token Report

Check a payload parses, and see what it will cost before you send it.

Your input

50 characters1 lines0 tokensor drop a file

JSON ValidatorExact
0Token change
Token change0no change
Input tokens0what you pasted
Output tokens0what you would send
Token cost of this result
Output tokens0
As input$0.00
× 100K requests$0.00

Everything on this page runs in your browser. Nothing you paste is transmitted, because there is no server here to transmit it to.

Result
 

Reading a parse error

The two failures that account for most invalid JSON are a trailing comma after the last element, and a single quote where a double quote belongs. Both are legal in JavaScript object literals and illegal in JSON, which is why they survive code review.

The error message reports the position where parsing failed, which is usually just after the real mistake rather than at it. Look at the character before the reported position first.

Why nesting depth is reported

Deep nesting costs tokens disproportionately: every level adds indentation to every line beneath it, and adds a brace pair of its own. A payload five levels deep spends a large share of its budget on structure.

It also correlates with model errors. Flat structures are read more reliably than deeply nested ones, so a depth figure above three or four is worth questioning on quality grounds as well as cost.

Validating model output, not just input

If you are checking JSON that a model produced rather than JSON you are about to send, use the LLM output validator instead. It strips the prose and code fences models wrap around their answers before parsing, and checks that the keys you require are actually present.

Frequently asked questions

Why does my JSON fail here but work in my code?
Almost always a trailing comma or single quotes. JavaScript accepts both in object literals; JSON accepts neither. Some parsers are also lenient in ways the specification is not, so code that works locally can fail against a strict API.
What is a reasonable nesting depth?
Three or fewer for anything a model reads. Beyond that both the token cost and the error rate rise, and flattening usually costs nothing you care about.

More format tools