JSON Formatter
Pretty-print and validate JSON
Loadingโฆ
Was this tool helpful?
About this tool
This tool validates JSON text and reformats it with indentation or collapses it to one line. It actually parses your input with JSON.parse, so a syntax error tells you exactly which line and column it happened on. Choose 2-space, 4-space, or single-line output.
How to use
- Paste JSON text into the input box, or click a sample button.
- Parsing happens as you type โ a red box appears for errors, and the formatted result appears below when the text is valid.
- Use the indent buttons (2 spaces / 4 spaces / one line) to change the output format.
- Use the copy button to grab the formatted JSON.
Frequently asked questions
- How are the line and column numbers in error messages calculated?
- JSON.parse reports a character position; this tool re-derives the line and column from that position using the line breaks in your input.
- Does this support JSON5 or JSON with comments?
- No. Only standard JSON syntax is supported. Comments, trailing commas, and single-quoted strings are all flagged as errors.
- What changes when I collapse to one line?
- Picking 'one line' in the indent options outputs the JSON with no whitespace or line breaks at minimum size, useful when you need a compact body for an API request.
- Is the JSON I enter stored on a server?
- No. Parsing and formatting all happen in your browser and are never sent to a server.