Skip to content

JSON Formatter

Format and validate JSON.

PASTE YOUR DATA
--indent
2 spaces
OUTPUT:
// paste JSON on the left
0 chars

Format and edit JSON

  1. [01]

    Paste JSON into INPUT, or click [SAMPLE] to load a demo payload. The tree appears after a short pause.

  2. [02]

    Choose 2 spaces, 4 spaces, 1 space or Tab from the indent menu. The tree, the copied text and the downloaded file all follow that choice.

  3. [03]

    Click an arrow to fold a subtree, or click a key or value to edit it. Press Ctrl/Cmd + Enter or click away to save; Escape cancels.

  4. [04]

    Use [compress] or [to xml] to switch the output view, then [copy] or [Download] to take that exact text with you.

// What the output controls do

  • >[compress] — Switches the result to one line of compact JSON.
  • >[to xml] — Writes the same data as XML. Array items are named item, and keys that are not valid XML names are cleaned up.
  • >[line no] — Adds line numbers to the current output view.
  • >[fullscreen] — Expands the result pane; press Escape to leave it.
  • >[Download] — Saves the current view as result.json or result.xml.
  • >[copy] — Copies that same text to the clipboard.

// A formatted example

IN

{"name":"Tom","age":30}

OUT

{ "name": "Tom", "age": 30 }

The same indent choice is used for the tree, [copy] and [Download].

// Questions about this tool

What happens when the JSON is invalid?

The result pane shows the parser message and a short excerpt of the input near the reported position, instead of a partial tree.

Will formatting round my numbers?

No. Parsing uses lossless-json, which keeps the original text of each number, so integers larger than JavaScript can represent exactly stay as written.

Does an edit change the input too?

Yes. Saving a key or value rewrites the INPUT pane with the edited JSON, so formatting again keeps your changes.