JSON Formatter and Beautifier

Turn minified or messy JSON into readable, consistently indented JSON. Errors are listed with their exact line and column while you type, and nothing leaves your browser.

Input
Output

    Nothing leaves your browser. Shortcut: Ctrl/⌘ + Enter runs the main action.

    What is a JSON formatter?

    A JSON formatter (also called a JSON beautifier or pretty-printer) takes JSON text and prints it again with one value per line and consistent indentation, so the nesting of objects and arrays is visible at a glance. The data does not change: whitespace between tokens is insignificant in JSON, as defined by RFC 8259 and ECMA-404. What changes is how quickly a person can find the field they are looking for in an API response, a log line or a configuration file.

    How to pretty-print JSON

    1. Paste the JSON into the input editor, drop a .json file onto it, or click Open file.
    2. Choose the indentation: 2 spaces, 4 spaces or a tab. Tick Sort keys to order the keys of every object alphabetically.
    3. Click Format (or press Ctrl/⌘ + Enter). The formatted JSON appears on the right, ready to copy or download.

    Example

    This minified response from an API:

    {"id":42,"user":{"name":"Ana","roles":["admin","dev"]},"active":true,"balance":12345678901234567890}

    becomes, with 2-space indentation:

    {
      "id": 42,
      "user": {
        "name": "Ana",
        "roles": [
          "admin",
          "dev"
        ]
      },
      "active": true,
      "balance": 12345678901234567890
    }

    Note the last value. In a formatter based on JSON.parse and JSON.stringify it would come out as 12345678901234567000, because JavaScript numbers hold only about 15–17 significant digits. IDs, account balances in the smallest unit and blockchain amounts often exceed that. Here the number text is copied through untouched.

    What happens when the JSON is invalid

    The formatter validates as you type. If the text is not valid JSON, the status line turns red and the problems list shows each error with its line and column; click an entry to jump to it. Typical problems are a trailing comma after the last item, a missing comma between two properties, single quotes, unquoted keys, comments, and brackets that do not balance. Click Fix JSON to repair them automatically and format the result in one step, or see the JSON validator page for how each error is detected.

    Formatting options explained

    JSON formatter questions

    What is the difference between a JSON formatter and a JSON beautifier?

    None: both names describe the same thing, re-printing JSON with line breaks and indentation so people can read it. Some tools also call it pretty-printing. The opposite operation is minifying.

    Should I indent JSON with 2 spaces, 4 spaces or tabs?

    JSON itself does not care. Two spaces is the most common choice in JavaScript projects and API documentation, four spaces is common in Python (json.dumps(indent=4)) and Java, and tabs make the file smaller and let each reader choose the width. Pick whatever your project's formatter uses so diffs stay clean.

    Why didn't my JSON format?

    Formatting needs valid JSON. If there is an error, the problems list shows where; fix it, or click Fix JSON to let the tool repair common mistakes such as trailing commas, single quotes and missing brackets, then review the result.

    Does Sort keys change the meaning of my JSON?

    No. RFC 8259 defines objects as unordered collections, so any compliant parser treats the sorted and unsorted versions the same. Sorting is useful before comparing two files or committing generated JSON. Array order is never changed.

    Are large numbers preserved?

    Yes. Many formatters run the text through JavaScript numbers and silently round 12345678901234567890 to 12345678901234567000. This formatter prints every number exactly as written, including trailing zeros such as 1.50.

    Can I format JSON Lines (NDJSON)?

    A JSON Lines file has one JSON value per line, which is not a single JSON document, so the validator reports content after the first value. Click Fix JSON and the lines are combined into one array that can then be formatted.