↑↓ to move ↵ to open Esc to close Browse all tools

JSON Formatter

Paste or drop JSON to pretty-print, minify or validate it, browse it as a tree or turn it into CSV. Broken JSON gets repaired, and everything stays in your browser.

Embed
Pasted JSON is formatted right away. You can also drop a .json file here. Ctrl + Enter or Cmd + Enter formats.

Output

Formatted JSON appears here.

Runs on your device. Nothing you enter is sent to a server.

Hand-checked listFree API Testing ToolsFree API clients for sending and testing requests, from open source desktop apps to curl, with free plan limits.

JSON Formatter by Freebiefy, free online tools · Privacy · Legal notice

Embed this tool on your site

Paste this code into your page. The tool runs in the visitor's browser, free and without signup. The height adjusts to the content. All tools you can embed

What is a JSON formatter?

JSON (JavaScript Object Notation) is a text format for structured data, defined in ECMA-404 and RFC 8259 and used by many web APIs and config files. Machines often send it as one long line, which is hard for people to read. A JSON formatter adds line breaks and indentation so you can see the structure at a glance. Config files in YAML turn into JSON with the YAML to JSON converter.

When JSON is the right format at all, against YAML for config files or CSV for tables, is covered in JSON vs YAML vs CSV. This tool also works as a validator. If the input is not valid JSON, you get a plain message with the line and column of the first problem. Minify does the opposite of formatting and strips all optional whitespace. The formatter works from your text, not from a converted copy, so long numbers, escapes and key order come out exactly as they went in.

Repair broken JSON

JSON copied from a JavaScript file, a Python print or a chat answer is often almost right. With Repair errors switched on, Format and Minify fix the usual suspects and tell you what they changed:

  • Trailing commas, comments and Markdown code fences are removed.
  • Single quotes and curly quotes become double quotes, and bare property names get quotes.
  • Python True, False and None become true, false and null, and JavaScript undefined or NaN becomes null.
  • Missing commas between values and brackets left open at the end are added.

Validate never repairs anything, so it always tells you whether the original text is strict JSON.

Tree view and JSON to CSV

Switch the output to Tree to fold and unfold objects and arrays. Each line shows how many keys or items sit inside, which makes it quick to find your way through a large API response. To CSV turns an array of objects into a table you can open in Excel, Google Sheets or Numbers: one row per object and one column per key. For more control, such as choosing columns, the delimiter or how arrays are split, use the JSON to CSV converter, and the CSV to JSON converter goes the other way. For a payload in Base64, decode it first with the Base64 decoder, and if your data holds dates as numbers, the Unix timestamp converter turns them into readable dates.

How to use the JSON formatter

  1. 1Paste your JSON, drop a .json file on the box or open one. Pasted text is formatted at once.
  2. 2Pick an indent and choose Format, Minify, Validate or To CSV. Turn on Sort keys to order object properties alphabetically.
  3. 3Fix any error at the line and column shown, or let Repair do it, then copy the output or download it.

Frequently asked questions

Is my JSON sent to a server?

No. Formatting, minifying, repairing and validation run in your browser. Files you open or drop are read by the browser too. Nothing you paste leaves your device, so it is safe to use with API responses and config files.

What does minify do?

Minify removes all spaces, tabs and line breaks that are not inside strings. The data stays the same, but the file gets smaller, which helps when you send JSON over a network or store it.

Why does my JSON fail to validate?

Common causes are trailing commas, single quotes instead of double quotes, property names without quotes, comments, and unescaped line breaks inside strings. JSON allows none of these. The error message shows the line and column where the problem starts, and Repair can fix most of these mistakes for you.

What does Repair JSON change?

It removes comments and trailing commas, turns single or curly quotes into double quotes, quotes bare property names, changes Python True, False and None to true, false and null, adds missing commas and closes brackets left open at the end. A notice lists every kind of change. Strings and numbers that were already valid are copied exactly. Check the result, because a guess about a missing bracket can be wrong.

How do I convert JSON to CSV?

Paste an array of objects, like a list of users or orders, and press To CSV. Every key becomes a column, nested objects become columns such as address.city, and arrays inside a row stay as JSON text. If the array sits inside an object, like {"data": [...]}, the first such array is used. Text that starts with =, +, - or @ gets a leading apostrophe, so a spreadsheet shows it as text instead of running it as a formula.

Does sorting keys change my data?

No. Sort keys only reorders object properties alphabetically, which makes two files easier to compare. Arrays keep their order. Note that JavaScript always lists keys that are plain whole numbers, like "7" or "42", first.

Are very large numbers handled exactly?

Yes. The formatter re-indents your text instead of converting the numbers, so 12345678901234567890 keeps every digit and 1.0 stays 1.0. The JSON standard (RFC 8259) warns that many programs read numbers as 64-bit floating point values, which are exact only for whole numbers up to 9,007,199,254,740,991, so keep large IDs as strings when the JSON goes into JavaScript.