Free Online Formatter:
Re-indent and normalize JSON6 with a choice of spaces or tabs and sorted or original key order.
TL;DR: Paste JSON6, choose an indent and key order, and copy the clean result. The formatter parses with json-6 and re-emits with JSON6.stringify, so output is canonical JSON6: unquoted simple keys, double-quoted strings, decimal numbers. Comments are not kept. Everything runs locally.
Format JSON6 Online
The sample is squashed onto a few lines on purpose. Change the options to see the layout change.
Private by design: everything runs locally in your browser using the reference json-6 parser. Your text is never uploaded, logged or sent to any server, and it is gone when you close the tab.
How the Formatter Works
The formatter is a round trip: JSON6.parse turns the text into a value, then JSON6.stringify(value, null, space, { sortKeys }) writes it back. space is a number of spaces (2 or 4), a tab character, or 0 for a single line, exactly like JSON.stringify.
Because formatting goes through a value, anything that is only syntax disappears: comments, quote choices, number radix, underscore separators and trailing commas. A hand-written 0b1010 comes back as 10. That is the right behavior for normalizing data, and the wrong one for hand-maintained files where the author's spelling matters; keep those out of an automated formatter.
What the Output Looks Like
- Keys: written bare when they are plain identifiers, quoted when they contain spaces, dashes, brackets or quote characters. By default they are sorted; choose "Keep original order" to preserve them.
- Strings: always double-quoted. A line break inside a string stays a raw line break, which JSON6 allows. An apostrophe inside a string is written as
\', which is valid JSON6 but not valid JSON. - Arrays: holes are preserved (
[1,,3]) andundefinedelements are written as the keyword. - Objects: a member whose value is
undefinedis dropped. - No trailing commas and no comments are emitted.
There is no quote-style option. That is a JSON5 stringify feature; the json-6 serializer does not offer it, so this page does not pretend otherwise.
Before and After
Input:
{zeta:1,alpha:{b:`x`,a:0b11},list:[1,,3]}Output with 2-space indent and sorted keys:
{ alpha: { a: 3, b: "x" }, list: [ 1, , 3 ], zeta: 1 }Note that the hole in the array is written on its own line as an empty member. Use the one-line indent setting for the compact [1,,3] form.
FAQ
Is my data sent to a server?
No. Everything happens in your browser.
Why were my comments removed?
Comments are not part of the parsed value, and the serializer can only write values. Keep a commented source file and format a copy.
Why is there a backslash before an apostrophe?
json-6 escapes single quotes inside double-quoted strings. It is valid JSON6; for strict JSON use the converter.
Can I get single-quoted strings?
Not from this tool. json-6 1.1.7 always emits double-quoted strings and has no quote option.
Keep Going
Validate your text, minify it, or read how JSON6 strings and numbers are written.