JSON formatter and validator

Format, validate, extract paths, unescape strings and convert JSONL while preserving number literals.

  • Runs locally
  • Free

Use the tool

Your files are processed in your browser and are not uploaded to a server.

About this tool

Format, validate and minify JSON with syntax highlighting, error locations and a collapsible tree. Extract with JSON Pointer, escape or unescape strings and convert JSONL, all while preserving large integers and long decimals exactly.

Typical uses

  • Pretty-print minified JSON from an API
  • Find the line and column of a syntax error
  • Pull one field or subtree out of a large document

How to use

  1. Paste or import JSON to format, validate, minify or explore its tree. Select a tree node to copy or download a subtree.

  2. Use JSON Pointer to extract a node or array fields, or escape/unescape a string and convert between JSONL and arrays. Process again after input edits.

Example

For {"data":{"items":[{"id":9007199254740993123}]}}, extract /data/items and project /id. The integer stays unchanged. To convert JSONL logs, provide one complete JSON value per line.

Good to know

Input: 1M characters / 4 MiB file; output: 5M characters; 128 levels and 50K keys/values; JSONL: 10K records. Number literals and duplicate keys are retained; ambiguous paths are rejected. Empty Pointer selects the root. Projection uses one pointer per line as output field names and rejects missing fields. Unescaping decodes one JSON string layer; JSONL rejects internal blank lines and multiline records.

Extraction uses JSON Pointer without evaluating expressions. Duplicate keys are retained and ambiguous paths are rejected; select a specific tree node instead. Unescaping decodes one double-quoted JSON string value, without recursively guessing its contents.

Common syntax errors and what the tool reports

Standard JSON (RFC 8259) is much stricter than a JavaScript object literal: keys and strings need double quotes, and comments, trailing commas, NaN and leading zeros are not allowed. The table shows, for each broken example, the first message and position the tool puts in the status line, copied from the tool’s own output. One mistake often triggers follow-up messages; fix the first one and validate again.

MistakeInputWhat the tool says
Trailing comma in an object{"a": 1, "b": 2,}Expected a double-quoted property name. (Line 1, column 17)
Trailing comma in an array[1, 2, 3,]Expected a JSON value. Empty input and trailing commas are not allowed. (Line 1, column 10)
Single quotes{'name': 'Ana'}Unexpected symbol in JSON. (Line 1, column 2)
Unquoted key{name: "Ana"}Unexpected symbol in JSON. (Line 1, column 2)
Comment{"a": 1 // note ↵ }Comments are not allowed in strict JSON. (Line 1, column 9)
NaN / Infinity{"ratio": NaN}Unexpected symbol in JSON. (Line 1, column 11)
Leading zero{"code": 012}Expected a comma. (Line 1, column 11)
Missing comma{"a": 1 "b": 2}Expected a comma. (Line 1, column 9)
Backslash in a Windows path{"path": "C:\data"}Invalid escape character in string. (Line 1, column 10)
Literal Tab inside a string{"text": "a[Tab]b"}Unescaped control character in string. (Line 1, column 10)
Two JSONL lines pasted{"id":1} ↵ {"id":2}Unexpected content after the JSON value. (Line 2, column 1)
Pasted text starting with a BOM[BOM]{"a": 1}Unexpected symbol in JSON. (Line 1, column 1)

How to fix it, by where the text came from

  • Copied from JavaScript code: quote the keys with double quotes, replace single quotes, and delete the comma after the last item and any comments.
  • A printed Python dict ({'a': True, 'b': None}): besides the quotes, change True / False / None to true / false / null.
  • NaN and Infinity have no JSON spelling (RFC 8259 rules them out). Use null, or the string "NaN" if the receiver knows to handle it.
  • A backslash starts an escape in a JSON string, so a Windows path must be written "C:\\data". Tabs and line breaks must be written \t and \n.
  • One JSON value per line is JSONL / NDJSON, not a single JSON document. In “Extract and convert”, choose “JSONL / NDJSON → Array”.
  • A UTF-8 file opened with “Import file” has its BOM removed while decoding; only a BOM pasted straight into the editor is reported. RFC 8259 says networked JSON must not start with a BOM.

Why number literals are kept as written

RFC 8259 notes that only integers between −(2^53)+1 and 2^53−1 are guaranteed to mean the same thing in every implementation. A browser’s JSON.parse turns every number into a double-precision float, so large order IDs and long decimals are silently changed. This tool slices number literals straight from your text; Format, Minify and Sort keys never pass them through a float.

LiteralJSON.parse then JSON.stringifyThis tool’s Minify
900719925474099390071992547409929007199254740993
123456789012345678901234567890123456700012345678901234567890
0.123456789012345678900.123456789012345680.12345678901234567890
1.011.0
1.25e+301.25e+301.25e+30
-00-0
1e400null1e400
The receiving program can still lose digits

The tool keeps the literal, but a program that parses it into an ordinary float will still get the middle column. IDs above 2^53 are safer sent as strings.

Duplicate keys, key sorting and indentation

RFC 8259 only says keys SHOULD be unique and that software behaves unpredictably when they are not. JSON.parse('{"id":1,"id":2}'), for example, keeps only the last one and returns id = 2; the first value is lost without a warning. This tool keeps both and flags the key: “Duplicate key "id". All values are preserved; sorting is disabled.”

  • “Sort keys” stops when keys are duplicated, with “Sorting stopped because duplicate keys exist. Resolve them first. Formatting and minifying preserve every duplicate.”, because after sorting there is no way to tell which value was meant.
  • Sorting compares UTF-16 code units, so capital letters come before lowercase and numeric keys are compared as text, not as numbers. Keys b, B, _, a, 10, 9 come out as: 10 → 9 → B → _ → a → b.
  • Format and Minify keep key order and string escapes as written (\u00e9 is not turned into é).

“Indent” offers 2 spaces, 4 spaces or Tab. The same sample order document has these character counts; Minify is the one to use for transfer or storage:

SettingCharacters
Minify111
2 spaces216
4 spaces296
Tab176

Sources

Frequently asked questions

Will large numbers lose precision?

No. Number literals are kept as written, never converted through JavaScript floats, so IDs and long decimals stay exact.

What about duplicate keys?

They are kept and shown in the tree so data problems are visible.

How large can the JSON be?

Up to 1 million characters or a 4 MiB file, 128 levels and 50,000 keys and values.