JSON Formatter & Validator: Format, Beautify, Minify and Validate JSON Online
Paste JSON into the formatter above and it is validated as you type. Valid JSON appears pretty-printed with two- or four-space indentation, ready to read or copy; invalid JSON shows the browser parser's error message with the position where parsing stopped. Format and Minify rewrite the input box in place, so you can keep editing the result.
Format, validate and minify
Format (also called beautify or pretty print) re-indents the JSON so nested objects and arrays are easy to follow. Choose two spaces, the common default for web projects, or four. The data does not change; only whitespace is added.
Minify does the opposite: it removes every space and line break outside strings to produce the most compact single line, useful for embedding JSON in a request, a config value or a test fixture.
Both buttons act only on valid input. If the JSON does not parse, pressing Minify or Format leaves the text as it is, so fix the reported error first.
Validation happens on every keystroke. The input is parsed with the browser's standard JSON.parse, the same strict parser your JavaScript code uses, so something that validates here will parse in your application.
This is a syntax check, the same job jsonlint or python3 -m json.tool does. It tells you the text is well-formed JSON, not that it has the fields your API expects: a response with "price": "12.50" where a number was expected validates without complaint. Checking structure and types is the job of a JSON Schema validator, or of your own code after parsing.
{"name":"DevToolGrid","tools":["json","regex","jwt"],"active":true}
{
"name": "DevToolGrid",
"tools": [
"json",
"regex",
"jwt"
],
"active": true
}
Reading the error message
When the JSON is invalid, the message comes straight from the browser's parser and usually includes a position, the character offset where parsing stopped. The real mistake is at that position or shortly before it.
{"a": 1,} Expected double-quoted property name ... trailing comma
{a: 1} Expected property name or '}' ... unquoted key
{'a': 1} single quotes are not allowed in JSON
{"a": NaN} NaN, Infinity and undefined do not exist in JSON
<!DOCTYPE Unexpected token '<' HTML page instead of JSON
A < at position 0 is special: the text is an HTML page, usually an error page, a login redirect or a 404 from the wrong URL, not JSON at all. Fix the request, not the text.
The opposite surprise is JSON wrapped in a string. A value copied from a log or a database column as "{\"id\":1}" is valid JSON: it is a single string, so the formatter shows it back as one quoted line instead of an object. Strip the outer quotes and the backslash escapes, or call JSON.parse twice in code.
Log files often hold JSON Lines, one object per line. Paste two of those lines and you get Unexpected non-whitespace character after JSON, pointing at the start of the second object: the first document was fine, and JSON allows nothing after it. Format one line at a time, or run jq . file.jsonl, which reads a stream of documents.
Some text fails because it only looks like JSON. Python's print() of a dict, {'id': 1, 'ok': True, 'note': None}, uses single quotes, True and None, and the parser stops at position 1 with Expected property name or '}'. Print the data with json.dumps() instead of copying its repr.
Strict JSON, not JavaScript
JSON is stricter than a JavaScript object literal. Keys and strings need double quotes, there are no trailing commas, no comments, and no undefined, NaN or functions. Configuration formats that look like JSON but allow comments, such as tsconfig.json or VS Code settings, are JSONC or JSON5, and a strict validator will reject them. Remove the comments first, or use a parser for that format.
Very large integers are another trap. JavaScript numbers are exact only up to 9,007,199,254,740,991, so a larger ID is displayed rounded after formatting. If your data contains 64-bit IDs, check them in the raw text, and send them as strings in your own APIs.
Using it as a JSON viewer for large or nested data
For API responses that arrive as one long line, formatting is the fastest way to see the structure: paste, and the nesting becomes visible. To pull a single value out of a large document, the JSONPath tester lets you query a path such as $.data.items[0].id without scrolling.
Formatting happens in the page, so very large documents of many megabytes may take a moment. For files of hundreds of megabytes, a command-line tool such as jq . file.json is the better choice.
Formatting JSON in code and on the command line
JSON.stringify(JSON.parse(text), null, 2); // JavaScript: pretty print
JSON.stringify(JSON.parse(text)); // minify
python3 -m json.tool data.json # validate and pretty print
jq . data.json # pretty print with colour
jq -c . data.json # minify
These use the same strict rules as the formatter above, so a document that fails here fails there too.
If the object is already in a browser tab, the DevTools console is quicker than pasting: copy(JSON.stringify(obj, null, 2)) puts a formatted copy on the clipboard. copy() is a console utility, not part of JavaScript, so it does not work in page code.
Is it safe to paste JSON here?
Yes. The JSON is parsed and re-indented by JavaScript inside this tab, and pasting or pressing Format sends nothing to a server; the Network panel of your browser's developer tools will show no request. That matters when the payload is a production API response with customer records or access tokens in it.
Frequently asked questions
How do I format JSON?
Paste the JSON into the formatter above. If it is valid, it is shown pretty-printed with two- or four-space indentation; click Format to rewrite the input in place, or copy the result.
How do I validate JSON?
Paste it into the formatter. It is parsed on every change with the browser's standard JSON parser, and any syntax error is shown with the parser's message and position.
What does minify JSON do?
It removes all whitespace outside strings, turning formatted JSON into one compact line without changing the data. It is useful for requests, configuration values and fixtures.
Why is my JSON invalid?
Look at the position in the error: the mistake is there or just before it. A `<` at position 0 means you pasted an HTML page rather than JSON. Otherwise it is usually a trailing comma, single quotes or an unquoted key carried over from JavaScript or Python.
Does the formatter change my data?
Formatting and minifying only change whitespace. The one exception is integers larger than 9,007,199,254,740,991, which JavaScript cannot represent exactly and shows rounded.
Is my JSON uploaded anywhere?
No. Everything runs in your browser; the JSON never leaves your device.