webdev_json_to_csv
Convert JSON arrays or objects into CSV text with customizable delimiter, quotes, headers, and nested object flattening.
Instructions
JSON to CSV Converter. Convert a JSON array of objects (or a single object) into CSV text, with a configurable delimiter, quote character, escape character, optional header row, null placeholder, boolean formatting, and optional flattening of nested objects into dotted-path columns. Use webdev_json_to_csv to turn structured JSON into spreadsheet-ready rows; for the reverse direction use webdev_csv_to_json, to pretty-print or validate JSON use format_json, and to fabricate demo rows use data_sample_data_generator. This tool only converts JSON to CSV (no reverse). Runs locally on the input you provide: read-only, non-destructive, contacts no external service, idempotent, and rate-limited (60 requests/minute for anonymous callers). Returns the CSV string plus validity, warnings, the discovered column headers, and row/column/size statistics.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| json | Yes | JSON text to convert. Best results with an array of flat objects; a single object becomes one row, and non-object array items are wrapped as index/value pairs. Must not be blank. | |
| delimiter | No | Field separator between columns (for example a comma, a tab, or a pipe). | , |
| enclosure | No | Quote character wrapped around fields that contain the delimiter, the quote character, or a newline. Empty string disables quoting. | " |
| escape | No | Character used to escape the enclosure inside a quoted field (defaults to doubling the quote, RFC 4180 style). | " |
| includeHeaders | No | Emit a header row of column names as the first line. | |
| flattenObjects | No | Expand nested objects into dotted-path columns (parent.child). When false, nested objects are JSON-stringified into a single cell. | |
| nullValue | No | Text substituted for JSON null, undefined, or non-finite numbers. | |
| booleanFormat | No | How boolean values are rendered in cells. | true/false |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| original | No | The submitted JSON text, echoed back. | |
| csv | No | The generated CSV text (empty string on failure). | |
| isValid | No | Whether the JSON parsed and converted successfully. | |
| errors | No | Fatal parse or conversion messages (empty when isValid is true). | |
| warnings | No | Non-fatal notices, such as nested objects being JSON-stringified. | |
| stats | No | Size and shape metrics for the conversion. |