Free Online Converter: JSON6

Convert JSON6 to strict JSON, or JSON to JSON6, with indent and key-order options.

TL;DR: Pick a direction, paste your text, and copy the result. JSON6 to JSON evaluates the value and re-serializes it with the browser's own JSON.stringify, so the output is always strict JSON any parser accepts. JSON to JSON6 writes it with JSON6.stringify. Everything runs locally.

Convert JSON6 and JSON

Choose a direction, then adjust indent and key order. The result updates as you type.

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 Conversion Works

JSON6 to JSON is a two-step process. The json-6 parser reads your text into a JavaScript value, then the browser's built-in JSON.stringify(value, null, indent) writes it out. Going through the native serializer guarantees strict JSON: double-quoted keys and strings, no comments, no trailing commas, decimal numbers only.

JSON to JSON6 reads the input with the native JSON.parse, so malformed JSON is rejected before conversion, then calls JSON6.stringify(value, null, space, { sortKeys }). That is the json-6 signature: value, replacer, space, then an options object. There is no quote-style option, unlike JSON5's stringify.

The key order setting maps to the json-6 sortKeys option. The library sorts object keys alphabetically by default; choosing "Keep original order" passes sortKeys: false. This only affects the JSON to JSON6 direction, because JSON.stringify always keeps insertion order.

What Changes on the Way to JSON

JSON has fewer value types than JSON6 syntax can express, so some content cannot survive the trip. These results come from running json-6 1.1.7 and the browser serializer:

JSON6 inputJSON output
CommentsRemoved
{ a: undefined }{} (member omitted)
[1,,3][1,null,3]
Infinity, -Infinity, NaNnull
0b1010, 0o755, 0xFF, 1_00010, 493, 255, 1000
Back-tick or multi-line stringsNormal string with \n escapes
A bare undefined documentError: nothing to serialize

Numbers are converted by value, so the radix and separators are lost. If you need to keep the original spelling of a number, JSON is the wrong target.

Going from JSON to JSON6

Any JSON document is already valid JSON6, so this direction exists to produce tidier output: unquoted keys wherever the key is a plain identifier, no quotes around them, and compact spacing. json-6 still writes string values with double quotes. It quotes keys that contain spaces, dashes, brackets or quote characters, so the result parses back.

Two behaviors are worth knowing. First, JSON6.stringify escapes a single quote inside a double-quoted string as \'. That is legal JSON6 but not legal JSON, so never feed that output to a strict JSON consumer; convert it back with the other direction first. Second, an object member whose value is undefined is dropped on output, while an undefined array element is written as the keyword.

For the parsing side of the story, including the node loader hooks, see the Node.js guide.

A Worked Example

This JSON6 input:

{ // build settings name: `app`, size: 1_024, mask: 0b1111, skipped: undefined, tags: ['a',, 'c'], }

converts to this JSON:

{ "name": "app", "size": 1024, "mask": 15, "tags": [ "a", null, "c" ] }

FAQ

Is my data sent to a server?

No. Parsing and serializing both happen in your browser. Nothing is uploaded or stored.

Why is JSON-to-JSON6 output sorted?

json-6 sorts object keys by default. Set Key order to "Keep original order" to pass sortKeys: false.

Can I convert whole files?

Yes, from the command line: json-6 -c file.json6 writes a sibling file.json. See the CLI page.

Does it keep my comments?

No. Comments are discarded when text is parsed into a value, so neither direction can preserve them.

Keep Going

Validate or format the same text, or convert whole files from the command line.