What is JSON and why format it?
JSON, short for JavaScript Object Notation, is the most common text format for moving data between programs. Web APIs return it, apps store settings in it, databases export it and browser extensions rely on it. Because it is designed for machines, it often arrives as one long line with thousands of characters, which makes it almost impossible to read, to compare or to debug. Formatting, also called pretty printing, puts every key on its own line and uses indentation to show the structure. Minifying does the opposite and removes every unnecessary space to make the data smaller. This page does both, finds syntax errors and offers a few handy conversions, all in your browser and without an account.
How to use the JSON formatter
- Paste your JSON into the box or drop a
.jsonfile on it. The file is read locally into the text box, where you can keep editing it. - Choose the indentation: 2 spaces, 4 spaces or tabs. Use whatever your team or style guide prefers; many JavaScript projects use two spaces, while a lot of API documentation uses four.
- Press Format for readable output or Minify for a compact single line. If you only want to know whether the text is valid, press Validate.
- Copy the output or download it as a file. If the JSON is invalid, an error message with the line and column appears, and the caret jumps to the problem in the input box.
Readable error messages instead of "Unexpected token"
Every developer has seen a message such as "Unexpected token } in JSON at position 214". It tells you where the parser gave up, but not what you did wrong. This tool runs its own strict check whenever the browser rejects your text, then explains the problem in plain English and points to the exact line and column. The most common mistakes it recognizes are listed below.
| Mistake | Example | Fix |
|---|---|---|
| Trailing comma | {"a": 1,} | Remove the comma before the closing bracket |
| Single quotes | {'a': 'b'} | Use double quotes for keys and strings |
| Unquoted key | {a: 1} | Write {"a": 1} |
| Comments | // note | JSON has no comments; delete them |
| Missing comma | {"a": 1 "b": 2} | Add a comma between properties |
| Invalid value | {"a": undefined} | Use null, a string or a number |
| Leading zero | {"zip": 02134} | Quote it: "02134" |
| Raw line break in a string | text broken over two lines | Use the escape \n |
If you copied the text from a log file or an email, look for smart quotes (“ ”), which look like double quotes but are different characters, and for characters that were cut off at the end of the selection.
More than pretty printing
Sort keys
Alphabetical key order makes two versions of the same object easy to compare, for example when you diff two API responses in a code review. Sorting is applied to all nested objects. The order of items inside arrays is never changed, because arrays are ordered by meaning.
Tree view
The tree view turns the data into collapsible branches, so you can open only the part you care about, in the same way as a file explorer. Branches are drawn when you open them, in chunks of 500 items, which keeps large files responsive. It is useful for exploring an unfamiliar API response before writing code to read it.
JSON to CSV
When the root of your JSON is an array of objects, such as a list of customers or orders, the tool can turn it into a spreadsheet-friendly CSV file. Each object becomes a row, and the union of all keys becomes the header row. Nested objects and arrays are written as JSON text in their cell. Text that begins with =, +, - or @ is prefixed with an apostrophe so that Excel and Google Sheets do not treat it as a formula, which protects you against formula injection when sharing the file. The downloaded CSV starts with a byte-order mark so that accented characters display correctly in Excel.
JSON to TypeScript
The TypeScript option reads your sample data and drafts interfaces. Objects of the same kind in an array are merged into one interface, and keys that are missing from some objects become optional (?). It is a quick starting point for typing an API response, but you should always review the output: a field that happens to be null in your sample may be a string in other responses, and a sample cannot reveal every possible value.
JSON versus similar formats
JSON is stricter than the JavaScript object literals it resembles. Keys must be quoted, comments are not allowed, trailing commas are forbidden and values are limited to strings, numbers, booleans, null, arrays and objects. Configuration formats such as JSON5, JSONC (used by editors for settings files) and YAML relax these rules, so a file that works in your editor may fail here. If you are checking an editor settings file with comments, remove the comments first. Dates have no native type in JSON, so they are normally written as ISO 8601 strings such as "2026-03-15T09:30:00Z". Very large integers beyond 9,007,199,254,740,991 can lose precision when parsed by JavaScript-based tools, including this one, so keep such values as strings.
Tips for working with large files
Files up to a few megabytes format in an instant. Above 5 MB the tool shows a warning because the browser needs more time and memory, and above 50 MB it advises you to use a desktop tool instead. For big files, prefer Minify or Validate over the tree view, close other heavy tabs and avoid editing in the text box while a long operation runs. Keep a backup of the original, since formatting normalizes spacing and can change how numbers such as 1.0 and 1e3 are written.
Privacy and API data
JSON often carries sensitive information: API keys, customer records, tokens or internal configuration. Many online formatters send your text to a server for processing. This page does not. The parsing, formatting and conversion are done by JavaScript in your own tab, the file is never uploaded, and the page works offline once it has loaded. That makes it a reasonable choice for production data, although you should still remove secrets before sharing results with others.
Frequently asked questions
How do I format JSON online?
Paste your JSON into the text box, choose an indentation and press Format. The tool parses the text, then writes it back with each key on its own line and nested levels indented. If the text is not valid, you get a message with the line and column instead.
What is the difference between format and minify?
Formatting adds line breaks and indentation so people can read the data. Minifying removes all unnecessary whitespace to make the file as small as possible for transfer or storage. Both produce the same data and can be converted into each other without loss.
Why does my JSON say it is invalid?
The usual causes are a trailing comma, single quotes instead of double quotes, unquoted keys, comments, a missing comma between items, or values like undefined and NaN. The error message names the problem and shows the line and column, and the caret jumps to that spot in your text.
Does the formatter change my data?
No values are changed. Whitespace and indentation are normalized, and escape sequences may be written in their shortest form. Sorting keys reorders the properties of objects, but never the order of array items. Very large integers over 2^53 can lose precision, so keep them as strings.
Can I convert JSON to CSV?
Yes, when the root is an array of objects. Each object becomes a row and the combined set of keys becomes the header. You can pick a comma, semicolon or tab delimiter, and the file can be downloaded. Nested values are written as JSON text inside the cell.
Is it safe to paste confidential JSON here?
The text is processed locally in your browser and is never uploaded or stored, and the page does not use cookies or analytics scripts. Even so, remove passwords, tokens and personal data when you only need the structure, especially before sharing a screenshot or output.
What does the JSON to TypeScript button do?
It reads the structure of your sample and drafts TypeScript interfaces, merging similar objects and marking missing keys optional. It is only a draft based on one example, so check union types and nullable fields against the API documentation before using it.
Is there a file size limit?
There is no hard limit, but performance depends on your device. The tool warns you above 5 MB and strongly above 50 MB. The tree view only draws branches as you open them, so it copes with large files better than printing every node.
Related tools
Need custom software, a faster website or help with digital projects? The team at Bilişim Ajans can help.