Advertisement

JSON Formatter & Validator

Beautify, minify and validate JSON, see the exact error line, fix common mistakes and browse it as a tree.

Last updated:

JSON Formatter
Beautify · Validate · Fix · Tree view
Paste JSON and press Format. Everything runs in your browser.

How to Format and Validate JSON

1
Paste JSON, upload a .json file or press Sample
2
Press Format / Beautify (or Minify to compact it)
3
If it is invalid, the error line is highlighted - press Fix errors for common mistakes

Your data never leaves the browser, so it is safe for API keys, tokens and private payloads.

Formatter, Validator, Viewer: What Each Does

FeatureWhat it doesAlso searched as
Format / BeautifyAdds line breaks and indentationjson pretty print, json beautifier, prettify json
MinifyRemoves spaces to make JSON smallestjson minifier, compact json, json one line
ValidateChecks syntax and shows the error linejson validator, json lint, json checker
Tree viewBrowse nested objects and arraysjson viewer, json explorer, json tree
Fix errorsRepairs common mistakesfix invalid json, json repair

Common JSON Errors and Fixes

ErrorExampleFix
Trailing comma{"a":1,}Remove the last comma
Single quotes{'a':'b'}Use double quotes only
Unquoted key{a:1}Wrap keys in double quotes
Comments// noteJSON has no comments - remove them
Python valuesTrue, NoneUse true, false, null
Missing comma{"a":1 "b":2}Add a comma between pairs
Unexpected end{"a":[1,2}Close every [ and {

JSON Syntax Rules (Quick Reference)

Pretty Print JSON in Code

Language / toolCommand
JavaScriptJSON.stringify(obj, null, 2)
Pythonjson.dumps(obj, indent=2)
Command line (Python)python -m json.tool file.json
jqjq . file.json
VS CodeShift + Alt + F (Format Document)
PHPjson_encode($obj, JSON_PRETTY_PRINT)

Why Use an Online JSON Formatter?

JSON vs Other Formats

FormatBest for
JSONAPIs, web apps, config
XMLOlder enterprise systems, SOAP, RSS
YAMLHuman-edited config (Docker, Kubernetes)
CSVSpreadsheets and flat tables

Format JSON Where You Already Work

WhereHow
Chrome / Edge DevToolsNetwork tab → click the request → Preview (tree) or Response
FirefoxOpens .json URLs in a built-in JSON viewer
Postman / InsomniaBody → Pretty
Notepad++JSON Viewer plugin → Format JSON
Sublime TextPretty JSON package → Ctrl+Alt+J
IntelliJ / WebStormCtrl+Alt+L (Reformat Code)

JSON Data Types With Examples

TypeExampleNote
String"Prajwal"Double quotes only
Number42, 3.14, -1e5No leading zeros, no NaN or Infinity
Booleantrue, falseLowercase
NullnullLowercase, not None or undefined
Object{"a": 1}Keys are strings
Array[1, "two", null]Mixed types allowed

Related Tools

Frequently Asked Questions

How do I format JSON online? +

Paste the JSON above and press Format / Beautify. Choose 2 spaces, 4 spaces or tabs for indentation.

How do I validate JSON? +

Press Validate. Valid JSON shows a green tick; invalid JSON shows the error with its line and column, and the line is highlighted.

How do I fix invalid JSON? +

Press Fix errors. It removes trailing commas and comments, converts single quotes, quotes bare keys and changes True/False/None to JSON values.

What is the difference between JSON beautify and minify? +

Beautify adds indentation for reading; minify removes all whitespace to make the file as small as possible for sending.

Is my JSON data safe? +

Yes. Formatting happens in your browser; nothing is uploaded or stored.

Can I view JSON as a tree? +

Yes. Format it and switch to Tree view to expand and collapse objects and arrays.

Why does JSON not allow comments? +

The JSON standard (RFC 8259) has no comment syntax. Remove comments or use JSON5/JSONC where your tool supports it.

How large a JSON file can I format? +

Several megabytes work smoothly in a modern browser. Very large files depend on your device memory.

About the creator Prajwal Karkera, creator of ToolsFlow

Built and maintained by Prajwal Karkera, a digital product specialist with 8+ years of experience in digital products. Found a problem with this tool? Let us know through the Contact page.
Read more about me →