How to Format and Validate JSON Online (Free, Instant)
A practical guide to formatting, validating, and minifying JSON — what common error messages mean, how to fix them, and a browser-based tool that works in real time.
To format JSON instantly: paste it into MyEasyTools JSON Formatter and it automatically pretty-prints the output, validates the structure, and highlights any errors. No account, runs entirely in your browser.
If you just need a quick reformat, that is all there is to it. If you are regularly dealing with messy, minified, or broken JSON, the rest of this guide covers the common problems and how to fix them.
Why JSON formatting matters
JSON (JavaScript Object Notation) is the data format used by virtually every web API, configuration file, and structured data export. Minified or single-line JSON is technically valid, but it is unreadable — a 3,000-character blob on one line tells you almost nothing about the structure.
When something breaks — an API returns an unexpected error, a config file is rejected, a data import fails — the first diagnostic step is almost always: format the JSON and read it. A well-indented JSON structure makes it immediately obvious if a key is misnamed, a value is the wrong type, or a closing bracket is missing.
Beyond readability, a formatter also validates: it tells you exactly where a syntax error is — not just "JSON parse error", but "unexpected token at position 847". That is substantially more useful.
What formatting actually does
A JSON formatter does two things in sequence:
- Parses the input string into a data structure in memory. This step validates whether the JSON is syntactically correct. If it fails, the error is reported with the position of the problem.
- Serialises the data structure back to a string with consistent indentation — typically 2 or 4 spaces — and one key per line.
The output is semantically identical to the input. {"a":1,"b":2} and the nicely indented multi-line version parse to the same JavaScript object; they are interchangeable wherever JSON is accepted.
Common JSON errors and what they mean
Unexpected token / Unexpected string Usually means a missing comma between properties, or a brace or bracket that does not match its partner. Check around the character position reported in the error.
Unexpected end of JSON input
The JSON is truncated — it ends before all structures are closed. This often happens when copying output from a terminal that wrapped long lines, or reading a partial API response. Count the opening braces and brackets: every { needs a }, every [ needs a ].
Property names must be double-quoted
JSON requires double quotes — "key" not 'key'. Single quotes are valid in JavaScript and Python strings, which causes confusion when writing JSON by hand.
Trailing comma
{"key": "value",} is not valid JSON. The comma after the last property is illegal. Many code editors allow trailing commas in JavaScript files (where they are valid), which trips people up when they copy the same syntax into a JSON context.
NaN and Infinity are not valid JSON values
These JavaScript primitives cannot be represented in JSON. If a serialiser produces them (usually a bug in the application), the resulting JSON is invalid. Replace with null or a numeric representation before parsing.
Step-by-step: format JSON with MyEasyTools
Go to JSON Formatter.
Paste your JSON into the input panel on the left. The formatter updates in real time as you type — no need to click a button.
Check for errors. If the JSON is invalid, the error message identifies the position of the problem. Fix the issue in the input panel and the error clears immediately.
Copy or download the formatted output from the right panel. Syntax is highlighted: keys in blue, string values in green, numbers in purple, booleans and null in amber/grey.
Minify if needed — a single button collapses the output back to a single line for use in API requests, config files, or anywhere whitespace adds unwanted size.
Formatted vs minified: when to use each
Formatted JSON is for humans — config files you maintain, API responses you're debugging, data files you need to read and edit. The extra whitespace has zero effect on behaviour.
Minified JSON is for machines and network payloads. A minified JSON payload is 20–30% smaller than formatted, which matters at scale. Use minified JSON for API requests, values embedded in code, or any situation where file size is a concern.
FAQ
Does it support JSON5 or JSONC (JSON with comments)? No — the tool parses standard JSON only. JSON5 and JSONC are supersets of JSON that allow comments, trailing commas, and unquoted keys. These are not valid JSON. If your file contains comments, strip them before pasting, or use a tool that explicitly supports JSON5.
Is there a size limit on what I can paste?
The tool handles JSON up to several megabytes comfortably in the browser. Files above 10 MB may be slow or cause the browser tab to struggle. For very large JSON files, a command-line tool like jq is more appropriate: jq . input.json > output.json.
Does my JSON get sent to a server? No — formatting runs entirely in your browser. Your JSON never leaves your device. This is particularly important for JSON that contains API keys, personal data, or database exports.
Format your JSON now at JSON Formatter →. If you are working with JSON property names that need to be normalised to camelCase or snake_case, Text Case Converter handles that conversion.