JSON Formatter and Validator
Pretty-print, validate, repair and minify JSON with exact line and column errors, live stats and a collapsible tree view. Everything runs locally in your browser.
Large input: over 3 MB the tree view is disabled to keep the page responsive. Formatting, validation and minify still work.
Tip: press Ctrl+Enter (Cmd+Enter on Mac) in the editor to format.
Loading... Private by design: your JSON never leaves the browser. No upload, no server, no logging.
A JSON formatter that runs entirely in your browser
Paste any JSON document and this tool validates it live as you type. When the document is valid you get a formatted view with syntax coloring, a collapsible tree, and structural stats: nesting depth, total keys, and how many objects, arrays, strings and numbers the document contains. When it is invalid you get the exact line and column of the first error, an excerpt of the offending line with a caret under the broken character, and a plain-English explanation instead of the cryptic native parser message.
Everything happens locally. Your JSON is never uploaded, stored or logged. That matters because the JSON people debug in 2026 is rarely public: it is API responses full of tokens, webhook payloads, LLM tool outputs and production configs. A formatter you can safely paste secrets into has to be client-side, and this one is.
Fix the mistakes that break most JSON
Strict JSON is smaller than most people expect. The specification allows no comments, no trailing commas, no single quotes, no unquoted keys, and no NaN or Infinity. Those habits come from JavaScript, JSON5 and config dialects like JSONC, and they cause the vast majority of parse failures. The usual sources are editors that autocomplete objects in JavaScript style, text pasted through Word or Slack that swaps straight quotes for smart quotes, and hand-edited configuration files.
The Fix common mistakes button repairs all of these in one pass: it strips comments outside strings, removes trailing commas, converts single-quoted strings and unquoted keys to proper double quotes, and normalizes smart quotes. It reports exactly what it changed, and it only rewrites your input when you click it, never silently.
Pretty-print for people, minify for production
Formatting is for humans reading a diff or debugging a payload. Production wants the opposite: minified JSON parses identically but drops whitespace, which cuts API responses and config files by 20 to 40 percent before compression even runs. Use two-space indentation for files that live in version control, sort keys alphabetically so diffs stay deterministic, and minify anything a machine consumes. If you build on WordPress, the same discipline applies to REST responses and plugin settings payloads.
JSON formatting and validation FAQ
Why is my JSON invalid when it looks correct?
The usual culprits are habits imported from JavaScript: a trailing comma after the last item, single quotes instead of double quotes, unquoted object keys, or NaN and Infinity as values. Copy-paste adds two more: smart quotes from Word or Slack, and invisible characters like non-breaking spaces. The validator above points at the exact line and column, and the Fix button repairs all of these in one click.
What is the difference between JSON and JSON5?
JSON5 is a relaxed superset built for config files written by humans. It allows comments, trailing commas, single quotes, unquoted keys, hex numbers and multi-line strings. Strict JSON allows none of that, and nearly every API, database and parser expects strict JSON. If a config file works locally but an API rejects it, you probably wrote JSON5. The Fix common mistakes button converts the most common JSON5 habits back to strict JSON.
Is it safe to paste sensitive JSON into this tool?
Yes. Everything runs as JavaScript inside your own browser tab. Your JSON is never uploaded, sent to a server, stored or logged, and the page makes no network requests with your data. You can load the page, disconnect from the internet, and the formatter keeps working. That makes it safe for API responses containing tokens, customer records or production configuration.
How do I fix an unexpected token error in JSON?
An unexpected token error means the parser hit a character it did not expect at that position. Use the line and column this tool reports, then look one character earlier: the real cause is usually a missing comma between items, a missing closing quote on the previous string, or a stray trailing comma. If the token is a single quote, a letter starting a bare word, or a slash starting a comment, the Fix button will repair it automatically.
Should JSON be pretty-printed or minified in production?
Minify anything a machine consumes. Whitespace adds 20 to 40 percent to payload size before compression and buys nothing at runtime, since parsers ignore it. Pretty-print anything a human reads: files in version control, documentation examples and debug logs. Two-space indentation is the common convention for committed files because it keeps deep structures readable without excessive line width.
How large a JSON file can a browser handle?
Modern browsers parse multi-hundred-megabyte JSON strings, but the practical ceiling is lower because the parsed object tree takes several times more memory than the raw text. This tool formats and validates documents of any size your tab can hold, and disables only the interactive tree view above 3 MB, since rendering hundreds of thousands of DOM nodes would freeze the page.
Does the order of keys in JSON matter?
Not to the specification: two objects with the same keys in different order are equivalent, and consumers must not rely on ordering. It matters to humans and to diffs. Sorting keys alphabetically makes committed config files deterministic, so version control shows real changes instead of reshuffles. The Sort keys A-Z toggle above applies recursive alphabetical ordering to every object in the document.
More free tools: Security Headers Checker · Meta Tag Checker · Bot User-Agent Lookup