Convert data between formats
Inputs
data(required): The data to convert, pasted as is (CSV, TSV, JSON, XML, a Markdown or copied spreadsheet table), with a note on anything you know about it (for example "ZIP codes must keep leading zeros").target_format(optional; one of: csv, json, markdown, xml, tsv; default: csv): Format to convert to. CSV and TSV open directly in Excel and Google Sheets.
Arguments fill these in order. If a required value is empty, take it from the user’s message or ask for it once.
- Identify the source format and structure: delimiter, header row, quoting, row count, column count, and whether it is flat or nested. Check that every row has the same number of fields; if some do not, list those rows and stop rather than guess where the fields belong.
- Map the structure to $target_format:
- CSV or TSV: one header row; quote fields per RFC 4180 (fields containing the delimiter, quotes or line breaks are wrapped in double quotes, and inner quotes doubled); for TSV, flag any value containing a tab or line break.
- JSON: an array of objects keyed by the header names. Numbers become JSON numbers only when they are plainly numeric and safe (no leading zeros, at most 15 significant digits, no thousands separators); identifiers, codes, phone numbers and anything with a leading zero stay strings. Empty cells become null only if the user says so; otherwise empty strings, and say which you chose.
- Markdown: a pipe table with a header separator; escape pipe characters inside values; keep right alignment for numeric columns.
- XML: a root element, one element per record, one child element per field. Header names that are not valid XML names (spaces, leading digits, symbols) are converted to valid ones and the mapping is listed; escape the characters & < > and quotes.
- From nested JSON or XML to a flat format: flatten nested objects into dotted column names (customer.address.city); for arrays, ask whether to explode them into one row per item or join them into one cell, unless the data makes one choice obviously right, and say which you used.
- Keep every value character for character: no trimming beyond the delimiter whitespace, no changed number formats, no rounding, no date reformatting, no case changes, no deduplication, no reordering of rows or columns.
- Count rows and fields before and after and report both.
Conversion notes
Rows and fields in and out, the source format detected, and each structural decision (null handling, flattening, renamed XML elements), one bullet each.
Ambiguous fields
Table: Field | What is ambiguous | What was done | What to confirm. Write "None found" if there are none.