Partial JSON parser
Parse JSON that has not finished arriving — a stream, tool-call arguments, a cut-off answer — into the longest valid value, each field complete or partial.
What it does
Paste JSON that stops part-way — what a stream has delivered so far, tool-call arguments as they arrive, or an answer cut off at max_tokens — and see the longest valid value that can be read from it. Every value is marked:
- Complete: its end has arrived, so it will not change.
- Still being written: an open object or list, a string that has not closed, a number that may have more digits (
12may become123). - Key only: a key whose value has not started. It is not in the value.
Stream it replays your text the way a stream delivers it, a few characters at a time, through the same parser; the slider moves through it by hand. Everything runs in your browser: nothing you paste is sent anywhere.
How it reads
The parser reads the text once, character by character, and keeps its place. Each new piece of a stream costs only its own length, so a long stream is not read again every time something arrives. A text over 100,000 characters is read in a Web Worker, so pasting or editing it never holds up the page.
What you get at any moment is valid JSON: every complete value, the open objects and lists closed where the text stops, and — unless you turn it off — the strings, numbers and true/false/null still being written, as far as they go. A key still being written, or a number that is not yet a number (-, 1., 1e), is left out: there is nothing valid to show for it.
A Markdown code fence around the JSON, which models often add, is skipped, and the result says so.
A number JavaScript cannot hold as written — an integer past 9,007,199,254,740,991, 1e400 (Infinity), 1e-400 (0), or more digits than a JavaScript number keeps — is listed with the value it reads as. The value shown and copied keeps the number as it arrived, so nothing changes quietly; a program that reads it with JSON.parse still gets the value it reads as.
What it does not know
- What comes next. A value that is still being written may change. Use only the complete values for anything that matters.
- Anything that is not JSON. It reads strict JSON as providers stream it: no comments, no trailing commas, no single quotes. At the first character that cannot continue JSON it stops, and shows the value up to there. To fix a finished answer that is broken, use JSON repair.
- The stream's framing. Paste the JSON itself, not server-sent event lines. The tool does not read
data:lines or a provider's delta format.
FAQ
How is this different from JSON repair?
JSON repair fixes a finished answer that is broken, and guesses where it has to. The partial JSON parser reads an answer that is not finished yet, guesses nothing, and says exactly which parts are complete.
Why is a number at the very end marked as still being written?
Until something follows it, the stream could still add digits. 12 followed by a comma is complete; 12 at the end of the text is not.
Sources
The grammar is JSON's (RFC 8259). No provider data is used: the tool works only on what you paste.
Where the numbers come from
This tool works only on what you enter. It uses no external data and runs entirely in your browser.
