All tools

JSON Formatter & Validator

Paste or upload JSON to format, validate, minify and explore it in your browser.

Browser onlyYour input is processed in this browser and is not sent to SpeedyTools servers.
Share:
Input

Paste valid JSON to see the output

Types:StringNumberBooleanNullObject Key

Format JSON online in your browser

An API response arrives as one long line, or a webhook payload sits in a log with no indentation. Paste it into the Input panel and this JSON formatter tidies it immediately, with consistent indentation and one key per line, so you can read the structure and find the field you need.

You don't need to press Format, because the output updates every time the input changes. If the text is not valid JSON, a red error bar shows the parser's message and the output panel stays empty until you fix it. The same parser also lets you minify JSON back to one line, or browse it as a collapsible tree.

Features

  • Runs in your browser, no upload to a server
  • Formats automatically as you paste or type
  • Live validation with the parser's error message
  • Collapsible tree with expand all, collapse all and depth levels
  • Search keys and text values, step through matches
  • Copy any single value or object from the tree
  • Minify to a single line
  • Copy the result or download it as formatted.json

How to format and validate JSON

  1. 1

    Paste or upload your JSON

    Paste JSON into the Input panel, or click the upload icon in the toolbar and choose a .json file from your device.

  2. 2

    Fix any errors

    If the text is not valid JSON, a red bar above the panels shows the parser's error message. Correct the input and the bar disappears.

  3. 3

    Pick an indent size

    Use the Indent menu to choose 2 spaces or 4 spaces. The formatted output updates straight away.

  4. 4

    Explore or view the text

    Use the Tree tab to expand, collapse and search the data, or the Raw tab to see the formatted JSON as plain text.

  5. 5

    Copy, download or minify

    Click the copy icon to copy the formatted JSON, the download icon to save formatted.json, or Minify to turn the input into a single line.

Toolbar at a glance

Indent
2 or 4 spaces
Format
Formatting is automatic
Minify
Rewrite the input on one line
Expand / Collapse all
Open or close every node
Depth...
Show the top 1 to 4 levels
Upload icon
Open a .json file
Copy / Download
Copy or save the indented output
Clear
Empty the input

Common JSON errors and how to fix them

The red error bar shows the message from your browser's own JSON parser, so the wording differs between Chrome, Firefox and Safari. It points to where parsing stopped, which is often just after the real mistake. These are the problems behind most invalid JSON:

Trailing comma

Invalid: {"id": 7, "tags": ["a", "b",],}

Valid: {"id": 7, "tags": ["a", "b"]}

JSON allows no comma after the last item in an array or object.

Single quotes

Invalid: {'name': 'Ada'}

Valid: {"name": "Ada"}

Keys and strings must use straight double quotes.

Unquoted keys

Invalid: {name: "Ada", age: 36}

Valid: {"name": "Ada", "age": 36}

JavaScript object literals allow this, but JSON does not.

Missing comma

Invalid: {"a": 1 "b": 2}

Valid: {"a": 1, "b": 2}

The error usually points at the next key, just after the missing comma.

Comments

Invalid: {"port": 8080 // dev only }

Valid: {"port": 8080}

Neither // nor /* */ comments are part of JSON.

Python or JavaScript values

Invalid: {"ok": True, "user": None, "score": NaN}

Valid: {"ok": true, "user": null, "score": null}

Use lowercase true, false and null. NaN, Infinity and undefined have no JSON form.

Smart quotes

Invalid: {“name”: “Ada”}

Valid: {"name": "Ada"}

Word processors and chat apps often replace straight quotes with curly ones.

Unescaped backslash

Invalid: {"path": "C:\Users\ada"}

Valid: {"path": "C:\\Users\\ada"}

A backslash inside a string must be written as \\.

Exploring large payloads with the tree view

The Tree tab shows every object and array as a node you can open or close. Collapsed nodes show how many items they hold. Use the expand all and collapse all buttons, or pick Level 1 to Level 4 from the Depth menu to see only the top of a deeply nested response.

Type in the Search box to highlight keys and string values that contain your text, ignoring case, and use the arrows to step through the matches. Search skips numbers and booleans. Hover over any line and click the small clipboard icon to copy just that value, or a whole nested object as indented JSON.

The tree gives strings, numbers, booleans, null and object keys their own colours, listed in the legend under the panels.

Your JSON stays on your device

The formatter uses your browser's built-in JSON parser. The page reads and formats pasted text and uploaded files itself and builds the download file locally, so API tokens or customer records in your JSON never go to a server for formatting.

The page sends anonymous usage events, such as the size of the input and output and which button was clicked, so we can see whether the tool works. The JSON content is never included.

What the formatter changes, and its limits

Changes you may notice

The tool parses your input and writes new JSON from the parsed data, so a few things can differ from your input.

  • Duplicate keys collapse to one. From {"a": 1, "a": 2} the output keeps only "a": 2.
  • Whole numbers larger than 9,007,199,254,740,991 lose precision, so 12345678901234567890 becomes 12345678901234567000. Keep large IDs as strings.
  • Keys that look like whole numbers, such as "2" and "10", move to the front of their object in ascending order.
  • The output normalises numbers, so 1.0 becomes 1 and 1e3 becomes 1000. It writes escapes such as \u00e9 as the character itself.

Known limitations

  • The tool accepts strict JSON only. It reports JSON5, comments, trailing commas and JavaScript object literals as errors.
  • Minify replaces the text in the Input panel. The copy and download buttons always give the indented version.
  • You can choose the indent size, but you cannot sort keys or change the spacing after colons.
  • Search works in the Tree view only and highlights matches without opening collapsed nodes.
  • Very large files can make the tree view slow, because it draws every node.

Tips for messy payloads

  • If the input starts with a quote, like "{\"id\": 1}", it is a double-encoded payload, meaning a JSON string that contains JSON. The tree shows it as a single string; copy that value with its clipboard icon, clear the input and paste it back in to format the inner JSON.
  • When you copy JSON from a log line, delete the timestamp and log level before the opening brace.
  • If an error points at a key, check the end of the line before it for a missing comma.
  • Use Raw view to check exactly what the copy button and download will contain.

When to use this formatter

It suits quick jobs: reading an API response or webhook body, tidying a request payload before pasting it into a ticket or docs, checking whether a config file is valid, or finding one field in a large nested document.

This page does not validate against a JSON Schema or query data with JSONPath or jq. Use a dedicated tool or your editor for those jobs.

Frequently asked questions

How do I format JSON online?

Paste your JSON into the Input panel above, or click the upload icon to open a .json file. As soon as the text is valid JSON, the formatted version appears in the output panel. Choose 2 or 4 spaces in the Indent menu, switch to Raw to see the text, then copy it or download it as formatted.json.

How do I format an API payload or request body?

Copy the body from your API client, browser dev tools or logs and paste only the JSON part into the Input panel. Remove anything around it, such as HTTP headers, a log timestamp or a variable assignment. If the payload is a JSON string with escaped quotes, see the double-encoded tip on this page.

Why does it say my JSON is invalid?

The tool uses strict JSON parsing, the same rules an API or JSON.parse applies. The most common causes are trailing commas, single quotes, unquoted keys, comments, missing commas and values like True, None, NaN or undefined. The red error bar shows your browser's parser message; check the spot it points to and the character just before it.

Is my JSON sent to a server?

No. Parsing, formatting, minifying and the tree view all run in JavaScript in your browser tab, and the page reads uploaded files locally. The page records anonymous usage events, such as input size and which button was used, but not the JSON itself.

Can I minify JSON here?

Yes. Click Minify and the Input panel is replaced with a single-line version with all whitespace removed. Copy the minified text from the Input panel. The output panel, the copy button and the download always use the indented version.

Is this JSON formatter free?

Yes. It is free to use, needs no sign-up and nothing to install.

Does it accept JSON with comments or trailing commas?

No. Comments and trailing commas are allowed in formats like JSON5 and some config files, but not in standard JSON, so the tool reports them as errors. Delete them and the input will format.

Is there a size limit?

There is no fixed limit. Everything is processed in your browser, so very large files depend on your device's memory, and the tree view can get slow because it draws every node. Collapse to a depth level or use the Raw view for big files.