Format, minify and validate JSON, or convert it to XML or CSV, directly in your browser. All processing happens locally; nothing is uploaded.
Formatted JSON will appear here.
Paste JSON on the left and click Format, Minify, To XML or To CSV.
Your text is first parsed with the browser's built-in JSON parser. If parsing succeeds, the resulting data is written back out as text. Format writes it with line breaks and the indent size you picked, placing every object property and every array item on its own line. Minify writes the same data with no spaces or line breaks at all.
Because the output is rebuilt from the parsed data rather than edited in place, it is always valid JSON. The same step also means a few details of your original text are not preserved, as explained below.
Input pasted from an API response:
{"name":"Asha","marks":[92,88],"active":true,"fee":1500.50}Format with 2 spaces:
{
"name": "Asha",
"marks": [
92,
88
],
"active": true,
"fee": 1500.5
}Two things changed besides the layout. A space was added after each colon, and 1500.50 became 1500.5, since both are the same number once parsed. Minify would return the input on one line with that same change to the fee.
Use Format when a person needs to read or review the data: debugging an API response, checking a configuration file, or comparing two payloads line by line. Four-space indentation is easier to follow in deeply nested data; two spaces keeps wide structures on screen.
Use Minify when the JSON will be stored or sent by a program, for example in an environment variable, a URL parameter, a database field or a request body, where line breaks are unnecessary or can cause problems.
{{ 'json-formatter.guide.convertXml' | translate: 'To XML wraps your data in a single root element. Each object key becomes a tag, and each item of an array repeats its parent's tag, so "categories": ["Finance", "Health"] becomes two "categories" elements in a row. A top-level array becomes a list of item elements. Characters such as &, < and > are escaped, and keys that are not valid XML names, for example ones starting with a digit or containing spaces, have the bad characters replaced with an underscore.' }}
To CSV turns an array of objects into a table: each object is one row and every key that appears in any object becomes a column. Nested objects are flattened into dotted column names, so owner.country holds the value of country inside owner. Arrays inside a row are kept as JSON text in one cell. Cells containing commas, quotes or line breaks are quoted the standard way, and the downloaded file opens correctly in Excel, including the rupee symbol and Hindi text.
| JSON | XML | CSV |
|---|---|---|
"name": "Asha" | <name>Asha</name> | Column "name" |
"owner": { "city": "Pune" } | <owner><city>Pune</city></owner> | Column "owner.city" |
"tags": ["a", "b"] | <tags>a</tags><tags>b</tags> | One cell: ["a","b"] |
"note": null | <note/> | Empty cell |
CSV can only show flat rows, so a single number or string cannot be converted, and deeply nested data is easier to read as XML or formatted JSON.