Skip to main content
SimpleToolbox

JSON Formatter

Beautify and validate JSON in the browser, then query it with JMESPath or export TypeScript and Go types.

Inputs stay in your browser
Browser Based
Free to use now
Local Only
Input JSON0 B
0 B

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.json or VS Code settings) is not RFC 8259 JSON. Strip comments or use Repair before treating the file as strict JSON.

Frequently Asked Questions

Can this tool fix invalid JSON?

Yes, to a degree. If you click the "Repair" button in the toolbar, our tool uses heuristics to attempt to fix the most common JSON syntax errors: single quotes instead of double quotes, and rogue trailing commas at the end of objects/arrays.

What happens to my data after I format it?

JSON you paste stays in the browser.

How do I generate TypeScript Interfaces from JSON?

Paste any valid JSON object or array into the left panel. On the right panel, select the "Export" tab and choose "TypeScript Interface" from the dropdown. The system recursively walks through your JSON properties, deduces their native types (strings, numbers, booleans, arrays), and builds a strict TypeScript interface definition you can copy directly into your codebase.

Is it safe to paste production API keys or database exports into this formatter?

JSON is parsed in this tab with JSON.parse(). Treat production keys like you would in any local editor: anyone who can see your screen or clipboard still can. Closing the tab clears the editor.

What is JMESPath and how do I use it to filter JSON?

JMESPath is a query language for JSON, similar to how XPath works for XML. It lets you extract specific fields or filter arrays from large JSON documents without writing any code. After pasting your JSON, click the JMESPath tab in the right panel and type a query — for example, users[?age > 30].name returns the names of all users where the age field exceeds 30. It is especially useful when working with large API responses or log files where you only need a small subset of the data.

What is the difference between JSON and JSONC?

JSONC (JSON with Comments) is a superset of JSON that allows // line comments and /* block comments */ — used in configuration files like tsconfig.json and VS Code settings. Standard JSON parsers reject JSONC because comments are not part of the RFC 8259 specification. If you paste JSONC into a strict JSON validator and see parse errors, strip the comments first using the Repair function or a text editor before processing.

Disclaimer

This tool is provided for informational and educational purposes only. Results are not a substitute for professional advice.

Found this helpful?

Share this free utility with your network.

Free Tools Alert

Get new tools, templates, and calculators in your inbox. No fake subscriber counts.

No spam. One-click unsubscribe.