Encoding & decoding

JSON Formatter & Viewer

Format, validate, and compact JSON, or explore its structure in a tree viewer. Your input stays in your browser.

01

Paste valid JSON, up to 100,000 characters. Your input stays in your browser.

Loading tool…
02
Ready when you are

JSON guide

How to format and explore JSON

An API response or configuration file can be difficult to read when everything sits on one line. A JSON formatter adds indentation and line breaks so you can follow the structure. A tree viewer lets you open individual objects and arrays when you want to focus on a particular part of the data.

Pretty print or compact output?

Paste your JSON into Input, choose an output format, and select Format JSON. Two-space indentation is a useful starting point for reading nested data; four spaces make each level more distinct. Choose Compact when you need the result on one line. It removes the formatting whitespace while keeping spaces inside string values, such as "Ada Lovelace".

Compact JSON

{"name":"Ada Lovelace","active":true,"skills":["math","programming"]}

The same example with two-space indentation

{
  "name": "Ada Lovelace",
  "active": true,
  "skills": [
    "math",
    "programming"
  ]
}

Read nested data with the tree viewer

After formatting, select Tree viewer to explore the parsed data. Open an object to see its properties, or an array to see its items. Array positions start at zero, so the first skill in the example is item 0. Expand all opens the available branches, and Collapse all closes them. Copy always copies the JSON text in your chosen format, whichever view is selected.

Common reasons JSON is rejected

JSON has stricter syntax than a JavaScript object literal. If you see an error beside the input, check these common mistakes:

  • Use double quotes for property names and strings: "name": "Ada".
  • Remove the trailing comma after the last property or array item.
  • Remove comments such as // note or /* note */.
  • Check for missing commas, closing braces, or closing square brackets.
  • Use lowercase true, false, and null. Values such as undefined and NaN are not JSON.

The formatter checks whether the text can be parsed as JSON. It does not check whether an API expects particular fields or whether their values follow a schema.

What to know before copying the result

Formatting parses your input and writes it back as JSON, so the output can change more than its spacing. Duplicate property names keep their last value, and very large numbers or precise decimals may be rounded by the browser. If your data format allows it, represent large identifiers as quoted strings when their exact digits matter.

Input is limited to 100,000 characters. The tree preview shows up to 1,200 values, 32 levels, and 500 characters per value to keep it manageable. Those preview limits do not truncate the formatted text or the copied output. The formatter also rejects data nested 128 levels deep or more.

Does the tool upload my JSON?

Formatting and tree viewing happen in your browser. This tool does not upload your input to the server. Use example loads sample data, and Clear empties the input and resets the result when you are ready to start again.

Further reading: the JSON standard, MDN on parsing JSON, and MDN on formatting JSON.

Comments

Ask a question or share how you use this tool.

Loading comments...

Browse tools