JSON Formatter, Validator & Tree Viewer

Raw input

Interactive tree

No JSON yet

Paste JSON on the left to format and validate it here.

APIMock teamUpdated

In short: a free, 100% client-side JSON formatter, validator and beautifier with an interactive tree view, in-place decoding of escaped/nested JSON strings, a local saved-snippet history, dual-mode search, and a full set of keyboard shortcuts. Everything runs in your browser, so your data never touches a server — safe for API payloads, access tokens, and config files.

It's built for developers who work with real API responses, logs, and configuration files all day. Paste raw JSON and it is parsed in a background worker, validated, and rendered as a navigable tree, without uploading a single byte.

How to format and validate JSON

  1. 1Paste your JSON. Paste or type JSON into the Raw input pane. Minified, single-line and pretty-printed JSON all work.
  2. 2Read the validation result. The tool validates the input half a second after you stop typing. Valid JSON appears in the tree; invalid JSON shows the error message with its line, column and a pointer to the exact character.
  3. 3Explore the formatted tree. Expand and collapse nodes, search with filter or highlight mode, and decode escaped JSON strings into navigable subtrees.
  4. 4Copy, download or save. Copy any node as JSON, download the document as a .json file, or save it to your local history to reopen later.

JSON formatting example

Minified JSON from an API response becomes indented, one value per line, and is shown as a tree you can fold:

Input (minified)
{"id":42,"name":"Ada","roles":["admin","dev"],"active":true}
Formatted
{
  "id": 42,
  "name": "Ada",
  "roles": [
    "admin",
    "dev"
  ],
  "active": true
}

Format, validate and fix JSON

  • Instant formatting & beautifying: Paste minified or messy JSON and read it as a clean, indented, color-coded structure.
  • Real-time validation with exact error lines: Invalid JSON is flagged immediately with the precise line number and message, so you can fix trailing commas, missing quotes, single quotes, or unquoted keys in seconds.
  • Non-blocking parsing: Validation runs in a background Web Worker, so even large API payloads and log dumps don't freeze the page.

Common JSON errors and how to fix them

These are the messages Chrome, Edge and Node.js report, and the ones this tool shows with the line and column. Firefox and Safari word them differently, but the causes are the same.

Error messageWhat it meansHow to fix it
Unexpected token '<', "<!DOCTYPE "... is not valid JSONThe input is HTML, not JSON — usually an error page, 404 or login redirect returned instead of the API response.Check the request URL, status code and authentication before parsing the body.
Unexpected end of JSON inputThe input is empty, or it was cut off before a closing } or ].Copy the whole payload, or check the response actually has a body (204 responses don't).
Expected double-quoted property nameA trailing comma before a closing brace, as in {"a": 1,}.Delete the comma after the last property.
Expected property name or '}'A key in single quotes or with no quotes, as in {'a': 1} or {a: 1}.Wrap every key in double quotes.
Expected ',' or '}' after property valueA missing comma between properties, or a // or /* */ comment after a value.Add the comma, and remove comments — JSON doesn't allow them.
Unterminated stringA string is missing its closing double quote.Close the string, and escape any double quote inside it as \".
Bad control character in string literalA raw tab or line break inside a string value.Escape it as \t or \n.
Unexpected non-whitespace character after JSONExtra text after the top-level value — a stray } or two JSON documents pasted back to back.Remove the extra characters, or wrap multiple documents in an array.
Unexpected token 'N' … is not valid JSONA JavaScript-only value such as NaN, Infinity or undefined.Replace it with null, a number or a quoted string.

Explore JSON in an interactive tree

  • Collapsible tree view: Navigate deeply nested objects and arrays with collapsible nodes and color-coded syntax highlighting.
  • Expand all / collapse all: Open the entire structure or fold it back to the top level in one click (or one shortcut).
  • Full-width mode: Hide the raw input and give the tree the whole width when you're reading large documents.

Decode nested and escaped JSON

API responses frequently embed an entire JSON document as an escaped string inside a field (for example "body": "{\"id\":1}"). Click Decode on that node — or on the whole document — and the tool parses the string in place and expands the result as a real, navigable subtree. Your original raw input is never modified, so you keep the source intact.

Search across raw input and the tree

  • Two search modes: Filter mode shows only matching nodes and their parents; highlight mode keeps the full tree and steps through matches with next/previous.
  • Search both panes: Find text in the raw input editor or in the rendered tree; search opens in whichever pane you last used.

Saved history, copy and export

  • Local saved history: Save JSON snapshots and reopen them later. Entries can be renamed, pinned to the top, and deleted, and they persist in your browser between visits.
  • Auto-save & restore: Your most recent input is stored locally and restored the next time you open the tool.
  • Copy anything: Copy the whole document, or a single object or array node from the tree as formatted JSON.
  • Download as .json: Export the current JSON to a file with one click.
  • Dark & light themes: Switch themes manually or follow your system preference; your choice is remembered.

Keyboard shortcuts

Every action has a keyboard shortcut, and each button's tooltip shows it. Shortcuts use Cmd on macOS and Ctrl on Windows and Linux.

ActionShortcut
Open search (raw input or tree)Ctrl + F
Toggle filter / highlight search modeCtrl + Shift + F
Download as .jsonCtrl + S
Copy raw inputCtrl + Shift + S
Save to historyCtrl + Shift + H
Expand all nodesCtrl + Shift + E
Collapse all nodesCtrl + Shift + L
Toggle full-width treeCtrl + Shift + X
Toggle dark / light themeCtrl + Shift + D
Clear the editorCtrl + Shift + Backspace
Close searchEsc

How it compares

FeatureThis toolTypical server-based tools
Data stays on your deviceYes — 100% client-sideNo — uploaded to a server
Free, no sign-upYesOften limited or gated
Exact error line numbersYesSometimes
Interactive tree viewYesRarely
Decode nested / escaped JSON stringsYesRarely
Saved snippet history (rename, pin)YesNo
Copy individual tree nodesYesRarely
Dark & light themesYesSometimes
Keyboard shortcutsYesRarely

Frequently asked questions

How do I format JSON online?

Paste your raw JSON string into the left pane. The tool parses it automatically and, if the JSON is valid, instantly renders it in the interactive tree view with proper indentation and collapsible nodes, making it highly readable.

Is this JSON validator safe for sensitive data?

Yes. Unlike many online tools that upload your data to a backend server, this JSON formatter runs entirely in your local browser using JavaScript. Your data is never transmitted over the internet, so it is safe for API payloads, tokens, and configuration files.

How do I fix invalid JSON syntax?

When you paste invalid JSON, the tool immediately flags the error and highlights the exact line number where parsing failed. This lets you quickly locate and resolve common issues like trailing commas, missing brackets, single quotes, or unquoted keys.

Why do I get an "Unexpected token" error in JSON?

An "Unexpected token" error means the parser hit a character that can't appear at that point in JSON. The most common one today is "Unexpected token '<'": you are parsing an HTML page (usually an error, 404 or login page) instead of a JSON response. Values JSON doesn't support, such as NaN or Infinity, cause it too, and older browsers also report trailing commas, single quotes and comments this way. The error pane shows the line, column and a pointer to the exact character.

What does "Unexpected end of JSON input" mean?

The parser reached the end of the text before the JSON was complete. Either the input is empty (a common cause is calling response.json() on an empty 204 response) or it was cut off before a closing } or ]. Check that you copied the whole payload, or that the API actually returned a body.

Is it safe to format JSON containing API keys or passwords?

Yes. Because all parsing, validation, and formatting happen client-side in your browser, secrets such as API keys, access tokens, and passwords never leave your device or reach any server. Nothing is logged or stored remotely.

What is the difference between JSON and JSON5?

Standard JSON is strict: it requires double-quoted keys, forbids comments, and disallows trailing commas. JSON5 is a superset that relaxes these rules, allowing comments, single quotes, trailing commas, and unquoted keys. This tool validates standard JSON, which is what virtually all APIs and config parsers expect.

What is JSON?

JSON (JavaScript Object Notation) is a lightweight data-interchange format that is easy for humans to read and write and easy for machines to parse and generate. It is widely used in REST APIs, web configuration files, and NoSQL databases.

How do I decode a JSON string that is escaped inside another JSON value?

API responses often store a whole JSON document as an escaped string inside a field (for example "payload": "{\"id\":1}"). Click the Decode action on that node — or decode the entire document from the root — and the tool parses the escaped string in place and expands it as a real, navigable subtree. Your original raw input is left untouched, so you never lose the source.

Are my saved JSON snippets kept private?

Yes. The history feature stores snapshots only in your browser's local storage on this device. You can save, rename, pin, and delete entries, and nothing is ever uploaded or synced to a server. Clearing your browser data removes them. The same applies to your most recent input, which is auto-saved locally so it is restored when you return.

Are there keyboard shortcuts for formatting JSON faster?

Yes. Every toolbar action has a keyboard shortcut, and each button's tooltip shows it. You can open search, download, copy, switch theme, expand or collapse the whole tree, toggle full-width view, save to history, and clear the editor without touching the mouse. The shortcut table on this page lists every binding (shown with Cmd on macOS and Ctrl elsewhere).

Can this tool handle large JSON files without freezing the browser?

Yes. Parsing and validation run in a background Web Worker, separate from the main interface thread, so pasting a large API response or log payload will not lock up the page. The interactive tree starts partially collapsed and you expand only the branches you need, keeping navigation responsive even on big documents.

Related tools and guides