A JSON formatter is a browser tool that pretty-prints, validates, and minifies JSON so you can read an API payload or config file and catch syntax errors. This page also queries JSON with JMESPath and can export TypeScript or Go types from a valid document.
How to format and validate JSON
Paste a JSON string into the left editor, then click Format to beautify it or Minify to strip whitespace. The tool parses the document with the browser's native JSON.parse() so invalid syntax is reported before the pretty-print is applied. Use Repair only when you want heuristics for common mistakes such as single quotes or trailing commas.
- 1 Paste your JSON: Copy your unformatted JSON payload from your API response, log file, or document and paste it into the left-hand editor pane.
- 2 Format or minify: Click the Format button to beautify the code, or Minify to strip out all unnecessary whitespace for production transmission.
- 3 Explore with Tree View: If your JSON document is massive, click the Tree tab on the right side to visually drill down into nested objects and arrays without getting lost.
- 4 Generate Types: Click the Export tab to automatically generate typed structures like TypeScript Interfaces or Go Structs based on the actual shape of your pasted JSON.
Tree view, JMESPath, and type export
After the document is valid, the right panel can do more than pretty-print. Tree view lets you open nested objects and arrays without scrolling a minified blob. The JMESPath tab runs queries such as users[?age > 30].name so you can extract a subset of a large API response. The Export tab walks the same object and writes a TypeScript interface or a Go struct you can copy into a codebase.
This page formats, validates, and queries JSON. If you need a spreadsheet or a YAML file, use the JSON to CSV converter or the JSON to YAML converter instead of asking this formatter to change formats.
Further reading: MDN — Working with JSON.
Why JSON stays in this browser tab
JSON you paste is parsed in this tab with JavaScript's native JSON.parse(), not a remote PHP or Python formatter. Closing the tab clears the editor.
Common JSON syntax mistakes
- Formatting before validating: Pretty-print will not invent missing commas. Validate first so the error line is visible.
- Single vs double quotes: JSON requires double quotes for keys and string values. Single-quoted text is a JavaScript object literal, not JSON.
- Unescaped characters: Backslashes, newlines, and tabs inside strings must be escaped (
\n,\t,\\) or the parser rejects the document. - Trailing commas and comments: JSONC (comments in
tsconfig.jsonor VS Code settings) is not RFC 8259 JSON. Strip comments or use Repair before treating the file as strict JSON.