JSON tools

JSON Formatter, Validator & Minifier

Format JSON online: paste, type or open a .json file, then beautify, validate or minify it in the same editor. Invalid JSON is left exactly as you wrote it, with the error reported by line and column. Nothing is uploaded — everything happens in your browser.

Paths start at the document: dot notation for properties, [0] for one array item, [*] for every item, ["a.b"] when a name contains a dot.

Try an example

Loading the editor…

All processing happens in your browser

Your JSON never leaves your device. Tab indents — press Escape then Tab to move focus out. Ctrl/⌘ + F searches inside the document. Ctrl/⌘ + Shift + P opens the path finder.

Keyboard shortcuts

Every shortcut below works in this editor. Windows and Linux keys come first, followed by the macOS equivalent where it differs.

Find & replace

Inside the panel, Enter jumps to the next match and Shift+Enter to the previous. Enter in the Replace field replaces the current match.

Open Find & Replace
CtrlF On macOS: ⌘F
Go to the next match
F3 or CtrlG On macOS: ⌘G
Go to the previous match
ShiftF3 or CtrlShiftG On macOS: ⇧⌘G
Close the panel
Esc
Add the next match to the selection (multiple cursors)
CtrlD On macOS: ⌘D
Select every occurrence of the selection
CtrlShiftL On macOS: ⌘⇧L
Go to line
CtrlAltG On macOS: ⌘⌥G

Path finder

The path finder resolves a JSON property path or an XML element path against the document and jumps to the exact token. Enter finds the path, and Enter again steps through the remaining matches.

Focus the path finder
CtrlShiftP On macOS: ⌘⇧P
Find the path, then step to the next match
Enter
Step to the previous match
ShiftEnter or ArrowUp On macOS: ⇧Enter or ArrowUp
Step through matches from the field
ArrowDown
Close the suggestion list, or clear the highlight
Esc

Tool actions

Format the document
CtrlShiftF On macOS: ⌘⇧F
Validate the document
CtrlShiftV On macOS: ⌘⇧V
Minify the document
CtrlShiftM On macOS: ⌘⇧M
Copy the document
CtrlShiftC On macOS: ⌘⇧C
Download the document
CtrlS On macOS: ⌘S

Folding

Collapse All folds every level, including nested structures — the same command the toolbar button runs.

Collapse the structure under the cursor
CtrlShift[ On macOS: ⌘⇧[
Expand the structure under the cursor
CtrlShift] On macOS: ⌘⇧]
Collapse everything
CtrlAlt[ On macOS: ⌘⌥[
Expand everything
CtrlAlt] On macOS: ⌘⌥]

Editing

Tab indents. To move focus out of the editor with the keyboard, press Esc first and then Tab.

Undo
CtrlZ On macOS: ⌘Z
Redo
CtrlY or CtrlShiftZ On macOS: ⇧⌘Z
Indent
Tab
Outdent
ShiftTab

How to format JSON online, validate it or minify it

  1. Add your JSON. Paste it into the editor, type it, choose Open file, or drop a .json file onto the editor.
  2. Pick an indentation. Choose the code indentation you want — 1, 2, 4 or 8 spaces, or tabs. The preference is remembered and the whole document is reformatted as soon as you change it.
  3. Run an action. Format beautifies, Minify strips optional whitespace, and Validate only checks the document without changing it.
  4. Find a value by path. Type a JSON property path such as object.game.name into the Path finder above the editor and press Find. It highlights that exact value, or explains why the path does not exist.
  5. Fold what you do not need. Use the gutter chevrons for a single object, or Collapse All to fold every level.
  6. Take the result away. Copy it to the clipboard or download it as a .json file.

JSON beautifier versus JSON minifier

Both actions read the editor's current content and write the result straight back into it, so there is only ever one copy of your document to think about. Formatting is for reading and reviewing; minifying is for shipping.

Minified input

{"name":"Ada Lovelace","langs":["JSON","XML"],"since":2013}

After Format with 2-space indentation

{
  "name": "Ada Lovelace",
  "langs": [
    "JSON",
    "XML"
  ],
  "since": 2013
}

The same document minified again returns to the single-line form above, character for character.

Why the JSON formatter never changes your values

A common way to build a JSON formatter is to parse the document and print it back out. That is convenient, but it is lossy: 1.0 becomes 1, 1e3 becomes 1000, integers beyond 253 lose precision, and duplicate keys collapse into one.

This tool re-indents the raw text instead, tracking string literals so that whitespace inside a string such as " x , y : z " is never touched. The only characters that can change are whitespace characters outside strings. Use Validate if you want a correctness check without any rewriting at all.

Integrity check: format a document, then minify it again. If the minified result matches what you started with, no data was altered.

Common JSON syntax errors and how to fix them

Trailing comma

JavaScript object literals allow a comma after the last property, but JSON does not. Remove it:

Invalid — reports “Expected a double-quoted property name” near the closing brace

{
  "name": "Ada",
  "langs": ["JSON", "XML"],
}

Single quotes or unquoted keys

JSON property names and strings must use double quotes. Replace {'a': 1} with {"a": 1}, and {a: 1} with {"a": 1}.

JavaScript-only values

undefined, NaN, Infinity, comments, functions and trailing semicolons are not part of JSON. Replace them with null, a number, or remove them.

Unterminated string or bracket

Every { needs a }, every [ needs a ], and every string needs a closing double quote. The error message names what was expected and where.

More than one top-level value

A JSON document is a single value, so two concatenated objects such as {"a":1} {"b":2} are invalid. Wrap them in an array instead.

JSON formatter features

  • Single unified editor. Paste, type or open a file and every action updates that one editor in place — no duplicated input and output panes.
  • Editor-level folding. Genuine CodeMirror 6 folding with chevrons in the gutter for every object and array, however deeply nested.
  • Global controls. Collapse All and Expand All act on the whole document and never modify the data.
  • Exact error positions. Line and column numbers plus an inline highlight on the offending line.
  • Keyboard first. Shortcuts for format, validate, minify, copy, download and folding, with no keyboard trap in the editor.
  • JSON path finder. Resolve a JSON property path such as object.game.name or array[0].name, with autocomplete from the document and a match count for paths that hit more than one value.
  • Light and dark themes. Syntax colours meet WCAG AA contrast in both.

Find a JSON value by path with the JSON path finder

The path finder resolves a path against the document that is really in the editor and jumps to the token it names, so a nested value in a large payload can be reached without scrolling for it. It follows the structure rather than the text, which is the difference between finding a JSON value by its path and searching for its text: object.game.name reads the value under that property even when the same key name occurs elsewhere in the file.

The syntax is small and predictable, and every path is relative to the document's root value:

  • Dot notation. object.game.name reads nested properties, to any depth. object and array are ordinary property names here, not keywords.
  • Array indexes. array[0].name is the name property of the first element. Indexes are zero-based.
  • Quoted bracket notation. object["game.mode"] reaches a key that contains a dot, a space or a bracket — anything dot notation cannot spell out.
  • Wildcards. array[*] matches every element and object.* every property, which is how a single path can match several values.

Examples for the document in the editor, which the tool derives from the document's own structure and refreshes whenever the content changes:

JSON property path examples

object.game.name      →  "Example Quest"
array[0].name         →  "Format"
object["game.mode"]   →  "a key containing a dot needs brackets"
tools[*].name         →  "JSON Formatter", "XML Formatter"

As you type, the field suggests properties and indexes read from the real document, so the exact key name never has to be guessed. A malformed path, a missing property and an index out of range each get their own message rather than an empty result, and when a path matches more than one value the match counter steps through them — every hit highlighted in the editor, in either theme.

JSON formatter frequently asked questions

What is a JSON formatter?

A JSON formatter (also called a JSON beautifier or JSON pretty printer) re-indents a compact or badly indented JSON document so its structure is readable: one level of indentation per nesting level, newlines between properties, and consistent alignment. A good formatter changes only whitespace, never your data.

How do I format JSON online?

Paste, type or open a .json file in the editor above, choose an indentation (1, 2, 4 or 8 spaces, or tabs), and press Format. The document is rewritten in place — there is no second output box to copy from. The same steps work for formatting JSON online on a phone or a shared machine, since nothing is installed.

How do I validate JSON?

Press Validate. The document is checked without being changed: if it is invalid, the offending line is highlighted, the caret moves to the problem, and the exact line and column are reported together with what was expected there. Valid documents get a success message and are left untouched.

What does the JSON validator actually check?

JSON as defined by RFC 8259 and ECMA-404: a single top-level value, double-quoted property names, no trailing commas, no comments, no unquoted keys, no undefined or NaN literals, correctly escaped strings and well-formed numbers. It is a syntax checker, not a schema validator — it does not know your data contract.

What is JSON minification?

JSON minification (minifying JSON) removes every optional whitespace character — spaces, tabs and newlines that sit outside string literals — so the document is as small as possible for transport. It is the opposite of formatting, and both operations preserve the data. Use Minify to strip whitespace and Format to put it back.

Does the formatter change my values?

No. Formatting re-indents the text and only removes or adds whitespace that sits outside string literals, so every token is preserved exactly. Numbers such as 1.0, 1e3 and integers larger than 2^53 keep their original spelling, and duplicate keys are not collapsed. Tools built on JSON.parse followed by JSON.stringify silently rewrite all of those.

How do I change indentation or collapse nested objects?

Pick 1, 2, 4 or 8 spaces or tabs in the Indentation dropdown; the whole document reformats immediately and the choice is remembered between visits. To collapse nested objects and arrays, click the chevron beside any value in the gutter, or use Collapse All to fold every level at once (Ctrl-Alt-[ and Ctrl-Alt-] do it from the keyboard). Folding only changes what is displayed, never the file.

Can I format large JSON files?

Yes. There is no fixed size limit. Documents above roughly 2 MB are worth a warning because formatting and folding a very large file can take a moment, but the editor is built to stay responsive on large inputs, and validation reports its error position without rewriting the document.

Is online JSON formatting safe?

Yes, with this tool: the formatter runs entirely in your browser using JavaScript, so your document is never sent over the network. You can confirm it yourself by watching the network panel in your browser developer tools while you work — no request carries your document. That makes it safe for private configuration, API payloads and customer data.

Can I use it offline or open a .json file?

Yes. Choose Open file to load a .json document from your device, or drag one onto the editor. Once the page has loaded it keeps working without a network connection, and Download saves the current editor contents as a .json file.

How do I find a value in JSON by its path?

Type the path into the path finder above the editor and press Find. The tool resolves the path against the document you can see and highlights the exact token, expanding anything that was folded on the way, then reports the line and column. Because it follows the structure rather than the text, it finds the right value even when the same property name appears many times in the file.

What path syntax does the JSON path finder understand?

Dot notation for properties (object.game.name), zero-based array indexes (array[0].name), quoted bracket notation for keys containing a dot, a space or a bracket (object["game.mode"]), and wildcards — array[*] for every element of an array, object.* for every property of an object. A leading $ is accepted but not required, and every path is relative to the document root, so object and array are ordinary property names rather than keywords.

Can the path finder read minified or badly formatted JSON?

Yes. The path finder resolves against the parsed document, so indentation makes no difference: a minified payload behaves exactly like a pretty-printed one. Resolution runs in the browser, the document is parsed once and reused for every query instead of on each keystroke, and searching never rewrites the content — you can keep editing while a path stays highlighted, and the highlight is dropped as soon as the text changes.

Related tool: the XML formatter

Working with markup instead? Use the XML formatter, validator and minifier, which offers the same folding, indentation and validation workflow for XML documents — or read the XML formatter FAQ first.