LLM JSON array to CSV
LLMs love to return a JSON array of objects, then bury it inside markdown fences or a paragraph of explanation. This tool digs the array out of that mess, flattens nested objects, unions every key into a column set, and hands you a properly escaped CSV — ready to open in a spreadsheet or pipe into a script.
How it works
The input is scanned for the first balanced [ ... ] array so code fences and
surrounding prose are ignored. The array is parsed with JSON.parse, then each
object is flattened: nested objects become dot-notation keys (address.city),
and nested arrays are serialised back to JSON inside a single cell. Columns come
from the union of all keys across all rows. Every value is CSV-escaped —
wrapped in quotes with internal quotes doubled — so commas, quotes, and
newlines survive intact.
Tips and notes
- Ask the model for an array of flat objects. The cleaner the JSON, the cleaner the CSV; deeply nested structures still convert but produce many dotted columns.
- Inconsistent keys are fine. Missing fields become empty cells rather than breaking the export.
- Numbers and booleans are preserved as text. CSV has no types, so
trueand42are written verbatim and re-typed by your spreadsheet on import. - Check the column count. A surprising number of columns usually means the model returned heterogeneous objects — useful to catch before downstream use.