JSON from an API or a log file usually arrives as one long unreadable line. Formatting it, also called pretty printing, adds indentation and line breaks so you can read the structure. This guide explains how to format JSON online free, when to minify instead, how validation works, and how to fix the errors that stop formatting.
What formatting does, and what it does not do
Formatting changes only whitespace: indentation, line breaks, and spacing. It does not change the data, the order of keys, or the values. A formatted JSON file and a minified JSON file contain the same data, and any correct parser reads both the same way. That is why formatting is safe: you can format, read, and minify back, without losing anything. The only thing formatting cannot fix is invalid JSON, which needs an error fix first.
Format, minify, or validate: which one you need
- Format (beautify). Use when you want to read JSON: inspecting an API response, reviewing a config file, or debugging a data feed.
- Minify. Use when you want the smallest output: reducing payload size, embedding JSON compactly, or storing it on one line.
- Validate. Use when JSON will not format, or before you send data anywhere. Validation reports whether the JSON is valid and shows the exact line and character of the first error.
Format JSON in four steps
- Paste your JSON into the tool below. Minified or already formatted, it does not matter.
- Choose indentation. Two spaces is common in JavaScript projects, four spaces in many style guides, and tabs in some editors. All three are valid.
- Click Format. The tool pretty prints the JSON with each key on its own line and nested objects indented.
- Copy or download the result. Use it in your code, config, or document, or switch to tree view to explore nested data.
Common JSON errors and how to fix them
- Trailing comma. A comma after the last item in an object or array is invalid. Remove it.
- Single quotes. JSON requires double quotes for keys and string values. Replace single quotes with double quotes.
- Unquoted keys. Every key must be in double quotes. Add quotes around bare keys.
- Missing comma. Two values without a comma between them fail. Add the comma.
- Comments. Standard JSON does not allow comments. Remove them, or use JSONC format if your tool supports it.
- Cut-off input. An unexpected end of input means a missing closing bracket, brace, or quote at the end. Check the end of the file.
Reading nested JSON fast
For deeply nested data, use tree view if the tool offers it: it collapses sections so you can open only the part you need. Search for a key name to jump to it, rather than scrolling. When comparing two JSON files, sort keys alphabetically in both, so differences stand out instead of hiding in different orders. These habits turn a wall of braces into a readable structure in seconds.
Privacy note for sensitive data
JSON often contains private data: API keys, personal records, or internal config. Prefer a formatter that runs in your browser, so your data never leaves your device. The tool below formats in your browser with no sign up. For highly sensitive data, still consider formatting locally in your code editor instead, as a matter of habit.
Try the free JSON formatter
The tool below formats, validates, and minifies JSON online, free and without an account. Paste your JSON, choose your indentation, and get readable output in seconds. When it will not format, read the error position it shows: the fix is usually one comma, quote, or bracket away.
