Settings

JSON

How it works

Why local

An online JSON formatter means pasting your data onto someone else's server: fine for a toy, wrong for a customer record or a token. This uses the browser's own JSON parser, so it accepts exactly what your code will, and nothing is uploaded. For bigger spreadsheet work see SPLIT and SHEETS; to decode other formats, DECODE.

Questions people ask about JSON

Why will my JSON not parse?

Usually for one of a handful of reasons, none of which JSON allows: a comma after the last item ({"a": 1,}), single quotes around a string or a key, a key with no quotes, a comment, or a value such as NaN or undefined. JavaScript accepts some of these in source code, which is why they slip in.

When the text will not parse, the line, the column and the character where it went wrong are shown under the box. The browser’s own parser decides what is valid, so the answer is the one your code will get.

Can it repair broken JSON automatically?

No. It tells you where the text stops being JSON and leaves the correction to you. A repair would have to guess what was meant, and a wrong guess, such as a quote closed in the wrong place, gives you valid JSON with different data in it.

How do I pull one value out of a large JSON document?

Type a path in the Query box and press Query. Keys are joined with dots and array positions go in brackets, so meta.tags[0] is the first tag inside meta. [*] applies the rest of the path to every item in an array, so [*].id lists the id of every object in a top-level array. A leading $ is allowed and ignored.

It is a plain path, not JSONPath or jq: there are no filters, no negative indices, and a key that itself contains a dot cannot be reached.

Why did a long number change when I formatted it?

Because JSON numbers are read as 64-bit floating point, the same as a JavaScript number, and that holds integers exactly only up to 253, which is 9,007,199,254,740,992. Beyond that the nearest representable value is kept, so 12345678901234567890 comes back as 12345678901234567000.

Your own code will do the same unless it parses big numbers specially. That is why APIs send long ids, such as database keys and snowflake ids, as strings.

How does JSON to CSV handle nested objects?

It expects an array of objects, or a single object. Each key becomes a column, in the order keys are first seen, and every row gets every column, left blank where that object has no such key or the value is null. A nested object or array is written into its cell as JSON text.

A cell that begins with =, +, - or @ and is not a plain number is written with an apostrophe in front, so a spreadsheet opening the file shows it as text rather than running it as a formula.

Why did the leading zeros go when I converted CSV to JSON?

Because a cell that looks like a number becomes a JSON number, and 01234 as a number is 1234. Cells reading true, false and null become those values too, and everything else stays a string. Postcodes, phone numbers and codes with leading zeros are better kept as strings, so check those columns in the result.

The separator is worked out from the header line: comma, semicolon, tab or pipe. A sep=; line at the top, as Excel writes, is honoured.

What happens if an object has the same key twice?

The last one wins and the earlier value is dropped without a warning. The JSON standard says names within an object should be unique but does not forbid duplicates, so the text counts as valid and the browser’s parser keeps the last value, as most parsers do. Formatting the document is a quick way to find out: the duplicate is gone from the result.

Doing this often? OBSCURA Umbra is a full code editor that runs Python and JavaScript in the browser, with git, search and replace across a folder. Everything is US$5 a month or US$48 a year.