vasilenko.info

JSON formatter and validator

/en/tool/json-formatter/ works tree view, repair, schema

Paste an API response, open a file, or enter a URL — the formatter will pretty-print the document with indentation. If parsing fails, it will show the line and column where the error occurred and offer to repair it. You can then use the same document in the tree view with paths, run JSONPath queries, validate it against a schema, compare it with a reference, and export it to CSV, YAML, or XML.

promoTwenty years of notes on websitesHow we did it in 2008 and what still works today.Open

Parsing and formatting

Input

JSON Lines (also known as NDJSON) — exports and logs where each line contains a separate record with no commas between them. The file is parsed line by line, so the number of a broken line is immediately visible while the remaining records are still read.

Indentation
Output

With line numbers, syntax highlighting remains enabled, but it is rendered by this tool rather than the site's general highlighting.

We first try to fetch the response directly in the browser. This works with APIs that allow cross-origin reads using the Access-Control-Allow-Origin header; the browser will block all others, and this will be stated clearly. Limit: 5 MB.

Drag a file here or into the field below

The file is read on your device and is not sent anywhere. The .jsonl and .ndjson extensions automatically enable JSON Lines mode.

An API response, file contents, or a log snippet. Comments, trailing commas, and single quotes are not allowed by the standard—the formatter will flag them, but the “Fix” button can remove them.

Result

Display as

Done

json

    Lines in result
    Records
    Total keys
    Nesting depth
    Characters in input
    Characters in result

    Parsing runs on your device in a separate thread, so the tab stays responsive even with a file several megabytes in size. The only thing ever sent out is a response fetched by the “Fetch” button. Everything else—pasted text, an opened file, a schema, or a reference—stays on your device. The draft and settings are saved in this browser and cleared with the “Reset” button.

    Selection and schema validation

    The expression extracts only what is needed from the document; the schema shows where the data diverged from the contract. They operate on the same document parsed above.

    Understands $, a dot, ["key"], [0], [*], the [1:3] slice, and two dots — search for a key at any depth: $..id. The match counter updates on every keystroke.

    Draft-07 to a practical extent: type, required, enum, const, minimum and maximum (including strict versions), minLength and maxLength, pattern, items, properties, patternProperties, additionalProperties, minItems, maxItems, uniqueItems, anyOf, allOf, oneOf, not, and $ref within the schema itself.

    What was found

    Expression not set

    json

      Schema validation

      Schema not set

        Compare with reference

        Both sides are first normalized — keys sorted alphabetically and indentation made consistent — and only then compared line by line. Otherwise, half the “differences” would be caused by a different key order.

        Second document: yesterday’s response from the same method, output from the production server, or an expected sample from the tests. On the left is what was parsed in the first panel; on the right is what is shown here.

        Line-by-line differences

        Reference not set

        diff
          promoCalculate ROI at the same timeCampaign payback based on spend and revenue.Open

          How to use it

          1. Provide the document in any of three ways: paste the text into the field, drag a file onto the dashed border or the field itself, or enter an address and click “Load”. Parsing starts immediately; you do not need to click a button.

          2. If parsing fails, the issue shows the line and column, and the button next to it moves the cursor directly to that position in the input field. The position marks where the parser realized it could not read any further; the typo itself is usually a couple of characters to the left.

          3. Fix broken JSON from someone else’s config or from a log with the “Fix” button. It removes trailing commas, changes single quotes to double quotes, quotes bare keys, removes comments, and replaces NaN, Infinity, and undefined with null. The issues list shows exactly what was fixed; nothing is replaced silently.

          4. The “Tree” tab is useful when a listing is impractical, such as in a response with three thousand lines. Nodes can be collapsed, and each one shows its type and number of elements. The buttons next to them copy the node path to the clipboard, both as $.items[3].id and as data["items"][3]["id"].

          5. The CSV, YAML, and XML tabs rebuild the same document in another format. CSV is generated from an array of objects: the columns are the union of the keys, and nested data is placed back into JSON inside a cell. The “Download file” button returns whatever is shown on the current tab.

          6. The JSONPath expression in the second panel extracts only what you need from the document: $.items[*].id returns all identifiers, and $..price returns all prices at any depth. The counter shows how many matches there are, and the listing shows exactly what matched.

          7. JSON Schema in the same panel checks whether the document conforms to the specified contract. Violations are listed with paths, so you see not just “does not match” but “$.items[2].price: expected a number, received a string”.

          8. Comparison with the reference in the third panel shows how two documents differ: line by line with annotations and in a separate list of paths. Key order does not affect the result; both sides are sorted.

          promoBrowser task listNo account required—everything is stored on your device.Open

          Example parsing: 88-character response

          The input data is the same as the default field values: you can calculate it mentally and confirm that the tool is telling the truth.

          1. There are four top-level keys — name, count, tags, and meta — plus two inside meta: open and path. Six in total.

          2. Nesting: the object itself is the first level; the tags array and meta object are the second. There is nothing deeper, so the depth is 2.

          3. Each array element and each key-value pair goes on its own line. The array and object brackets also each take up a line.

          4. In the tree, there are three top-level nodes with values and two collapsible nodes: tags is an array with 3 elements, and meta is an object with 2 keys. The path to the third tag is $.tags[2], or data["tags"][2].

          The result is 13 lines: the opening bracket, name, count, “tags”: [, three tags, the array’s closing bracket, “meta”: {, open, path, and two closing brackets. There are 6 keys and a depth of 2. The expression $.tags[*] returns three matches. The CSV tab will not work with this document because CSV is generated from an array of objects, while the root here is an object.

          Frequently asked questions

          promoAll toolsForty-four tools, all running in your browser.Open

          Related tools

          6

          MD5 and SHA hashes

          Calculates MD5, SHA-1, SHA-256, and SHA-512 hashes for a string or file.

          Open

          Password generator

          Creates passwords of the required length and assesses how difficult they are to crack.

          Open

          Timestamp converter

          Converts Unix time to a date and back, taking the time zone into account.

          Open