JSON formatter & converter
Format, validate, minify and convert JSON.
How to use
Paste JSON and choose an action. Format indents it with 2 or 4 spaces or tabs; Validate checks the syntax and shows the type of the top-level value, how many top-level keys or elements it holds (not counting nested ones) and the number of characters; Minify removes all unnecessary whitespace; Tree view shows nested objects and arrays as a collapsible tree. Ctrl+Enter (Cmd+Enter on a Mac) in the input box formats.
Validation follows the JSON standard (RFC 8259) as your browser reads it. Property names and strings need double quotes; true, false and null are lowercase; trailing commas, comments, single quotes, NaN and Infinity are not allowed. When parsing fails, the error message explains why and, when the browser reports a position (Chrome and Firefox do for most errors), the line and column where it stopped.
Formatting and minifying read the data and write it out again, so a few things can change beyond the whitespace: whole numbers larger than 9,007,199,254,740,991 can lose precision, numbers with more than about 17 significant digits are rounded, numbers too large for JavaScript (such as 1e400) become null, 1.0 becomes 1 and 1e3 becomes 1000, a key that appears twice in the same object keeps only its last value, keys that look like whole numbers (such as "1" or "10") move to the front of their object in numeric order, and most \u escapes become the characters they stand for. Store long IDs as strings to keep them exact.
CSV turns an array of objects into one row per object, with a header made from every key in the order it first appears; missing and null values both become empty cells and nested objects or arrays are written into the cell as JSON. A single object becomes one row, and an array of plain values becomes a single column called value. Choose a comma, semicolon or tab as the separator; spreadsheets in countries that use a decimal comma often expect the semicolon.
YAML conversion writes every string value in double quotes, and quotes keys such as yes, no, on, off, true, false and null, so YAML 1.1 parsers do not read them as true, false or null. Everything runs in your browser; nothing is uploaded.
Example
Formats the sample object with indentation. The values stay the same; only the layout changes.
{"name":"Ana","active":true}Formats as an indented object with two keys.{"name":"Ana",}Invalid JSON because of the trailing comma. Browsers that report a position point to line 1, column 15.[{"id":1,"tags":["a","b"]},{"id":2,"name":"Ana"}]CSV with three columns: id, tags and name. The tags cell holds the array as JSON text in quotes, and the missing name of the first object is an empty cell.{"id":12345678901234567890}Valid, but formatting writes 12345678901234567000: the number is beyond the precision of a JavaScript number.{"country":"no"}YAML: country: "no", quoted so that it stays a string.
Frequently asked questions
Does formatting change my data?
Usually only the whitespace. The exceptions are very large or very precise numbers, numbers written as 1.0 or 1e3, duplicate keys, keys that look like whole numbers (which move to the front) and \u escapes, which are written back in their standard form. Values that must stay exact, such as long IDs, should be strings.
Can I use comments or trailing commas?
Not in JSON. JSON5 allows both, and JSONC allows comments and, in some parsers, trailing commas, but standard JSON parsers reject them. Remove them before validating.
Why does my object work in JavaScript but fail here?
A JavaScript object literal accepts unquoted keys, single quotes, trailing commas and comments. JSON accepts none of these.
Is my JSON uploaded?
No. Parsing and conversion happen locally in your browser.