OnlineNotes Logo

    JSON Formatter

    Format and validate JSON payloads for APIs, config files, and test fixtures.

    Input

    Output

    Ready

    Type

    -

    Lines

    0

    Chars

    0

    When to use this tool

    Use this JSON formatter when reviewing API responses, preparing test payloads, or cleaning config files.

    You can validate and normalize structure quickly before shipping data changes.

    Frequently asked questions

    Does this JSON formatter validate malformed input?

    Yes. The tool reports parse errors with helpful messages when the JSON input is invalid.

    Can I sort keys recursively?

    Yes. Enable key sorting to normalize object key order across nested structures.

    Can I switch between pretty and minified JSON?

    Yes. Toggle minify mode for compact output or use indentation for readable JSON.

    Related tools

    JSON formatter and validator online for API payload debugging

    Use this JSON formatter and validator online to pretty-print an API response, find out why a payload will not parse, or minify it.

    Recursive key sorting gives objects a stable order, which makes test snapshots and code review diffs easier to read.

    How it works

    1. Paste JSON and press Format JSON. Typing alone only marks the draft as changed. Changing an option reruns the format straight away.
    2. The tool parses the text with the browser's JSON.parse. If that fails, the output is cleared, the status shows Invalid JSON, and the browser's error message appears, usually with a position.
    3. Options: indent with 2 spaces, 4 spaces, or a tab. Sort keys orders keys in every nested object and leaves array order alone. Minify output removes all whitespace and overrides the indent choice.
    4. Below the output you see the root type (object, array, string, number, boolean, or null), the line count, and the character count.

    Worked example

    Input

    {"name":"Ann","id":12345678901234567890,"tags":["b","a"],"meta":{"z":1.0,"a":null}}

    Output

    {
      "id": 12345678901234567000,
      "meta": {
        "a": null,
        "z": 1
      },
      "name": "Ann",
      "tags": [
        "b",
        "a"
      ]
    }

    With Sort keys on and 2-space indent. Keys are sorted, including inside meta, but the tags array keeps its order. Look at the numbers: the long id lost its last digits and 1.0 became 1, because the tool formats parsed values and not your original text.

    Edge cases and limits

    • Numbers pass through JavaScript number parsing. Integers above 9007199254740991 lose precision and values change with no warning, so do not use the output for long IDs. "1.50" becomes 1.5 and "1e3" becomes 1000.
    • Only strict JSON is accepted. Comments, trailing commas, single quotes, and unquoted keys all give an error, and nothing is repaired for you. The error wording depends on your browser.
    • Duplicate keys are not reported: the last value wins and the earlier one disappears. So {"a":1,"a":2} keeps only "a": 2, which can hide a real bug in the source.
    • Number-like keys always come first in ascending order, even with Sort keys off, because of how JavaScript objects work. Sorted keys use language-aware order, so "a" comes before "b" and "B" follows "b". There is no JSON Schema validation.

    When to use it

    • Format an API response body so you can read it.
    • Check pasted JSON before you send a request.
    • Minify a payload to compare its size.
    • Put object keys in a stable order in fixture files.