Benchvale

JSON formatter that cites the RFC section for each rewrite

A JSON formatter indents and checks a document in this tab, so nothing you paste is uploaded. When a rewrite is lossy, the page cites the RFC section that allowed it. When a document does not parse, it names the line and the column and points a caret at the character. Format, minify, and sort keys are modes.

Sample

.json and .txt only, 5 MB cap. A file within the cap replaces the text in the box, but a large one shows its name there, not its text.

Options

top-level keys only

RFC 7159 and ECMA-404 accept the same grammar as RFC 8259 for this page.

Paste JSON

Result

values rewritten

Waiting for JSON.

Spec validated against: -

When a document does not parse, this page names the line and the column, prints that line back, and points a caret at the character.

Need another step? Send this to the tool chain and decode, format or hash it in one place.

Measured from what you pasted
Valid JSON
·
In / out
·
Lossy rewrite
·
Parse
·
Network requests
·
Our own script
·

Marked helpful once.

Was this tool useful?

Your JSON never leaves your browser: this page doesn't send it to us or anywhere else. Once the page has loaded, you can disconnect and keep working. How we build tools
Requests: · listed · unlisted Script · Updated

Check the offline claim yourself, in thirty seconds

Paste your JSON in. The result appears as you type. No request carries what you pasted. Now, with the page still open, turn off your wifi and TYPE A DIFFERENT DOCUMENT: it still works.

That test works on any tool, not just this one, and it is the only reliable way to answer the question. A privacy policy describes an intention. A network tab shows you what happened. We wrote the longer version of that argument in is it safe to paste JSON into an online formatter, including what to do when the answer turns out to be no.

On our side the claim is enforced rather than remembered. Before any update to this page goes live, an automated check types into the box and presses every button, and blocks the update if what it typed turns up in a request. It is described in how we build tools. Loading the page itself does need a connection.

The error message is the feature

Formatting valid JSON is arithmetic and every tool does it identically. The place these tools differ is what happens when the JSON is broken, which is most of the time, because valid JSON did not need a formatter.

When a document does not parse, this page names the line and the column, prints that line back, and points a caret at the character. Jump to error moves the caret in the paste box to that reported location.

One caveat worth knowing: the parser reports where it noticed the problem, which is not always where the problem is. A missing closing brace is usually noticed at the end of the document. If the marked line looks fine, the mistake is normally a little above it.

Sorting keys, and why it is here

Sort keys rewrites the document with the top-level object's keys in character-code order: capitals before lowercase, and "10" before "2". Nested objects are left as they were. The control says top-level keys only for that reason. Paired with the diff checker it still helps when two payloads differ only in the order of top-level fields.

What this deliberately does not do

No load from a URL, no conversion to XML, CSV or YAML, no JSON Schema validation, no editing inside the tree, and no auto-repair. A repair that guesses at missing quotes or trailing commas can change the document while appearing to fix it. When something is invalid here, you get told where, and the correction stays yours.

Questions

How do I format JSON?

Paste it into the box, or open a .json or .txt file up to 5 MB. The formatted result appears as you type, indented by 2 spaces unless you pick 4 or a tab under Options. Minify strips whitespace. Sort keys puts the top-level keys in character-code order, so capitals come before lowercase and "10" comes before "2".

What does "Unexpected token" mean in a JSON error?

The parser hit a character JSON doesn't allow at that spot. Chrome and Node.js word it that way. A < at the very start usually means the server sent back an HTML page, not JSON. Paste the text here and you'll get the line and column instead. A trailing comma in an array is flagged at line 4, column 1 when that ] sits alone on line 4.

Why does it say my JSON is invalid when it looks fine?

Look for a trailing comma, single quotes or a comment. JavaScript accepts all three. JSON accepts none of them. The caret lands on the spot where the parser noticed the problem, and that isn't always where the mistake is. A missing closing brace usually shows up at the end, so if the marked line looks fine, check the lines above it.

Can it check a JSON Schema or fix broken JSON?

No to both. It validates against RFC 8259, or RFC 4627 if you choose it, and there's no schema check. It won't repair anything either. A fixer that guesses at a missing quote can change your data while it looks like it's helping. You get the line and column, and the fix stays yours.

Why does it sometimes say the output isn't my input?

Because sometimes it isn't. Numbers are read as JavaScript doubles, so 12345678901234567890 comes back as 12345678901234567000. If a key appears twice in one object, only the last value survives. When that happens, the page lists the key, both values and the RFC 8259 section that leaves duplicate keys to the implementation, so you don't copy a changed document by accident.

Is my JSON uploaded?

No. Formatting runs in this tab, and a share link keeps the document after the # in the address, which browsers don't send to a server. You can check for yourself: open your browser's network tab and paste. Is it safe to paste JSON online covers how to test any formatter.

Related tools

If you are deciding whether to paste JSON into this tab at all, is it safe to paste JSON into an online formatter is the check. Got two versions of a payload? The diff checker can sort keys on both sides first, so a reordered response stops reading as a rewrite. Pasting the middle segment of a JWT? That is base64, specifically the URL-safe alphabet. And when you need several of these in a row, the tool chain runs them in sequence on one paste.

Maintained by Aaron Wilson
Published . Last updated . How the tools work and how we check them: how we build tools. Something wrong? Tell us.