JSON Parser & Formatter
Paste JSON or upload a file to validate and format instantly.
Upload a .json or .txt file (max 5MB)
How Validation, Escape, and Sort Actually Work Here
Format, Minify, and Validate all run your input through the browser's native JSON.parse() โ so error messages are exactly what V8 or your browser's engine reports, like Unexpected token } in JSON at position 47. That position number is a character offset into your raw input string; count from the start of your pasted text (including whitespace) to find the exact spot, rather than assuming it refers to a line number.
Escape and Unescape don't operate on individual string values inside your JSON โ they treat the entire contents of the input box as one string. Escape runs JSON.stringify() on your whole input as a plain string (wrapping it in quotes and backslash-escaping internal quotes/newlines), which is exactly what you'd want when embedding an entire JSON document as a single string value inside another JSON payload. Unescape does the reverse with JSON.parse() โ paste a quoted, backslash-escaped string and it returns the raw unescaped text (or, if what you pasted parses to an object/array instead of a string, it pretty-prints that structure instead).
A Gotcha in Tree View: String Values Aren't HTML-Escaped
The Tree View renderer builds its output as an HTML string and inserts each JSON string value directly via innerHTML without escaping angle brackets first. In practice this means a JSON value like "bio": "<b>VIP</b>" will render as actual bold text in the tree view rather than the literal characters <b>VIP</b> โ the tree view is treating your data as markup, not displaying it as text. This is purely a visual quirk in the Tree View panel (the Format/Minify text output is unaffected and shows your data correctly as plain text), but it's worth knowing if you're inspecting JSON that might contain HTML-like strings, so you don't mistake rendered markup for the tree misreading your data.
What "Sort Keys" and "Convert to CSV" Actually Require
- โ Sort Keys only reorders object properties, never array items: it recurses into every nested object and sorts its keys A-Z, but array element order is always preserved exactly as written โ sorting doesn't reorder a list of records, only the field order within each object.
-
โ
The "Convert to CSV" button only appears for a top-level array of plain objects: it stays hidden for a single object, a nested/mixed array, or an array of primitives โ check
checkOutputValidity()'s logic and you'll see it explicitly testsArray.isArray()plus that every item is a non-array object before revealing the button. - โ CSV headers are the union of keys across every object, not just the first: if record #1 has fields A and B while record #2 adds field C, the CSV gets three header columns and record #1's C cell is simply left empty โ no error, no misalignment.
-
โ
Nested objects/arrays inside a record aren't flattened into their own CSV columns: a nested object value gets
JSON.stringify()'d and dropped into a single quoted CSV cell as a JSON string, rather than being split into dot-notation sub-columns the way some dedicated flattening libraries do.
Frequently Asked Questions
The error says "Unexpected token at position 132" โ how do I find that spot?
That number counts characters from the very start of your pasted text, including all whitespace and line breaks. In most code editors you can use "go to character offset" or paste into a text editor with a character counter to zero in on the exact spot; often the real problem is one or two characters before the reported position, like a missing comma on the previous line.
Why does the Tree View show bold or linked text instead of the literal string I typed?
The Tree View inserts string values as raw HTML rather than escaping them first, so a value containing HTML-like tags gets rendered as markup instead of literal text. This is cosmetic and only affects the Tree View โ Format and Minify output your data as exact plain text.
Why is my "Convert to CSV" button missing?
It only appears when your JSON, after Format/Minify, is a top-level array where every element is a plain object (no arrays, strings, or numbers mixed in). Wrap or restructure your data into that shape first, e.g. [{...}, {...}], not a single object or an array of arrays.
Does Sort Keys change the order of items in my array?
No โ it only sorts the property names within each object alphabetically. If your JSON is an array of records, the records stay in their original order; only the field order inside each record changes.
What happens to a nested object when I convert to CSV?
It's serialized as a single JSON-string cell (e.g. "{""city"":""NYC""}") rather than split into separate columns. If you need flattened columns for nested data, restructure the JSON to pull nested fields up to the top level before converting.
