JSON Formatter
Format, validate, and minify JSON with inline error reporting.
Recommended tools
Free CDN, DNS, and edge hosting for developers.
Affordable domains and SSL certificates.
Affiliate links — we may earn a commission if you sign up.
About the JSON Formatter
JSON Formatter parses, validates, and pretty-prints JSON while keeping a minify mode handy for when a single line is all you want. Type or paste into the Input JSON textarea and the conversion runs on every keystroke, so the result always matches the current document. The two tabs control the shape: Format expands your object using the Indentation dropdown, which offers 2 spaces, 4 spaces, or Tab, while Minify collapses every level of nesting into a compact single line. Validation is the engine behind both modes, because the tool feeds your text through a real JSON parser before it emits anything. Broken syntax never reaches the ResultBox; instead a red alert prints the exact JavaScript parser message and the output box waits quietly until the JSON is fixed. The stat row below the buttons reports Input size, Output size, the bytes Saved, and Compression percentage, which makes it easy to demonstrate how much whitespace Minify strips. Clear empties the workspace, Load sample restores the ready-made Fernandes Labs object, and Copy result puts the formatted or minified text on your clipboard. You can also download the output as formatted.json or minified.json directly from the result box.
Examples
{
"name": "Fernandes Labs",
"tools": ["json", "yaml", "xml"],
"version": 1,
"open": true,
"nested": {"a": 1, "b": 2, "list": [1, 2, 3]}
}{
"name": "Fernandes Labs",
"tools": [
"json",
"yaml",
"xml"
],
"version": 1,
"open": true,
"nested": {
"a": 1,
"b": 2,
"list": [
1,
2,
3
]
}
}{
"name": "Fernandes Labs",
"tools": ["json", "yaml", "xml"],
"version": 1
}{"name":"Fernandes Labs","tools":["json","yaml","xml"],"version":1}{"name": "Fernandes Labs",}No output — a red alert prints the JavaScript JSON.parse error and the result box shows Fix the error above to see output.
How to use
- 1
Select the Format tab for pretty-printing or the Minify tab to collapse whitespace into one line.
- 2
Paste your JSON into the Input JSON textarea; the sample is preloaded, so use Load sample to restore it.
- 3
On Format, pick 2 spaces, 4 spaces, or Tab from the Indentation dropdown to control nesting depth.
- 4
When a red alert appears, fix the reported JSON syntax and the output rewrites itself automatically.
- 5
Copy result to grab the text, or use the download in the result box to save formatted.json or minified.json.
Common use cases
- Prettifying a minified API response before reviewing it in a code review or bug report.
- Packing a readable configuration object into one line for environment files or single-line flags.
- Validating hand-edited JSON from a teammate before it enters a production pipeline.
- Demonstrating exact byte savings when a build step argues about file size.
- Standardising indentation across a repository that mixes 2-space and 4-space files.
- Preparing JSON fixtures for tests or generated docs with consistent, copyable formatting.
Best practices
- Validate config files here before committing them, since a single bad comma can break a pipeline.
- Agree on the Indentation setting with your team, because 2 spaces versus tabs causes endless review noise.
- Use Minify only for network payloads; keep the Formatted version in source control for readable diffs.
- Round-trip critical files through Format and Minify and compare bytes to confirm nothing was altered.
- Start from Load sample before pasting big documents so the textarea keeps a known-good reference.
- Fix the exact position the red alert reports instead of guessing at the whole document.
Tips
- Use the Compression stat after Minify to quantify how much whitespace you removed for a file-size report.
- Switch to Tab indentation when the output lands in a codebase that standardises on tabs.
- Run Load sample in both tabs back and forth to learn Format and Minify on identical input quickly.
- Watch the Saved tile for negative numbers, which means minifying inflated the size and the input was already minimal.
Frequently asked questions
Explore more developer tools
Browse the full collection of developer tools on the hub, or jump back to all categories.