JSON is the lingua franca of APIs, config files, and logs, and it is also famously unforgiving: one stray comma and the entire document refuses to parse, with a browser error message that often points nowhere useful. This formatter fixes that workflow. Paste your JSON and you can format it with readable indentation, minify it down to a single line, or validate it and get the exact line and column of the first syntax error.
Everything runs locally in your browser. Your JSON, whether it is an API response, a config file with secrets, or a data export, is parsed in the tab and never sent to any server. There is no signup, no size gate beyond your device's memory, and it works equally well on mobile and desktop.
Beyond the three main actions, the tool includes a collapsible tree view for exploring nested data visually, a copy button, a download button for saving the formatted result, and a sample JSON button that loads a realistic example so you can experiment before pasting real data.
What Is JSON and Why Does It Break So Easily?
JSON, short for JavaScript Object Notation, has a deliberately tiny grammar. Objects are key-value maps in curly braces, arrays are ordered lists in square brackets, and the only legal value types are strings, numbers, true, false, null, objects, and arrays. The strictness is the trap. Keys must be double-quoted strings. Strings must use double quotes, not single quotes. Trailing commas after the last item of an object or array are forbidden. Comments do not exist in JSON. Numbers cannot be written as NaN or Infinity.
Because every byte matters, a document that renders as 2000 lines of nested data can be invalidated by a single character. The most frequent offenders, in rough order of how often they appear in real-world debugging:
- A trailing comma after the final item, for example a comma following the last key-value pair before a closing brace.
- Single quotes around keys or strings, usually copied from JavaScript or Python code.
- Unquoted keys, another JavaScript habit that JSON rejects.
- Comments, which are valid in many config formats but not in JSON.
- Smart curly quotes pasted from word processors or chat windows instead of straight double quotes.
- A missing brace or bracket somewhere deep in the nesting, so the parser runs out of input before the structure closes.
How to Use the Formatter (Step by Step)
- Paste your JSON into the input area, or click the sample JSON button to load an example document and see how the tool behaves.
- Click Validate first if the JSON came from an unknown source. If the syntax is broken, the error is reported with its line and column position in the original text.
- Choose your indentation: 2 spaces, 4 spaces, or a tab. The 2-space style is the most common convention in modern tooling.
- Click Format to pretty-print, or Minify to strip all unnecessary whitespace for transport or storage.
- Use the tree view to explore the structure: objects and arrays collapse and expand, and every value is shown with its type.
- Copy the result to the clipboard or download it as a file when you are happy with it.
Format, Minify, and Validate: What Each Mode Does
| Mode | What it does | Typical effect |
|---|---|---|
| Format | Pretty-prints with your chosen indentation, one key per line | A 2.4 KB config becomes readable and diff-friendly |
| Minify | Removes all non-essential whitespace and line breaks | The same file typically shrinks 25 to 35 percent, for example 2.4 KB to about 1.6 KB |
| Validate | Parses the text without altering it and reports the first syntax error | A precise line and column pointer instead of a vague failure |
Formatting and minifying never change your data. Keys, values, and their order are preserved exactly; only whitespace between tokens differs. Key order is not sorted alphabetically, which matters when a consumer of the JSON depends on insertion order, as some logging and hashing tools do.
Reading the Tree View
Nested JSON is hard to read as text: an API response with three levels of objects and arrays turns into a wall of braces. The tree view renders the same data as a collapsible hierarchy. Arrays show their length next to the bracket, objects show their key count, and leaf values display with their type visible at a glance, so a string, a number, and a null are never confused. Click any object or array to fold its entire subtree into a single line. This is the fastest way to answer questions like what keys does this response actually contain or where is that nested field I need.
How Error Positions Are Calculated
Under the hood the tool calls the browser's JSON.parse, which stops at the first syntax error it meets. The raw parser error reports a character offset; the formatter converts that offset into a line number and a column, counting lines the way text editors do, starting at line 1 column 1. Two practical notes: fix the first reported error and re-validate rather than trying to fix everything at once, because a single missing brace can cascade into several misleading downstream complaints. And remember that an error at line 40 is sometimes caused by an unclosed bracket that opened at line 12; the reported position is where the parser gave up, not necessarily where the mistake lives.
JSON vs JavaScript Object Literals
The similar names cause endless confusion. A JavaScript object literal, the thing you write inside a .js file, allows comments, unquoted or single-quoted keys, trailing commas, and shorthand values. JSON allows none of these. If your formatting fails right after you copy config out of a JavaScript file, look for those four habits first. Conversely, any valid JSON is also a valid JavaScript expression, which is why JSON works so naturally in that ecosystem. One subtle detail: JSON.parse silently keeps the last occurrence of a duplicated key, so two identical keys in one object are not reported as errors; if duplicate keys matter for your data, search the text for them manually.
Tips and Best Practices
- Keep a formatted master copy of any JSON you edit by hand, and minify only at build or deploy time. Diffing minified one-line JSON is nearly impossible.
- Prefer 2-space indentation for shared files; it is the de facto standard in most modern repositories and tooling.
- Validate API responses before debugging your own code. Far too many bugs blamed on application logic are actually a 500 error page or an HTML string pretending to be JSON.
- Use the download button to save formatted output for code review, then diff it against the previous version.
- For very large payloads, tens of megabytes or more, expect the tree view to get slow; browsers hold everything in memory. Multi-hundred-megabyte JSON belongs in command-line tools, not a browser tab.