When to convert JSON ↔ CSV
API arrays need to open in Excel; CSV lists need to become JSON for code. ComTools offers two local tools:
Both run in the browser for small/medium tables. For large xlsx files, use Excel to JSON / Excel to CSV.
JSON → CSV
Rules
| Item | Details |
|---|---|
| Input | Array of objects (keys from the first object = headers) |
| Output | Header row + data rows, comma-separated |
| Values with commas | Auto-quoted; " → "" |
| File export | Export CSV adds a UTF-8 BOM for Excel |
Empty/non-array input → empty output.
Steps
- Open JSON to CSV.
- Paste an object array (or Sample).
- Run to preview CSV text.
- Copy, or Export CSV as
data.csv.
Example
Input:
[
{"Id": 1, "Name": "Alice", "Email": "alice@example.com"},
{"Id": 2, "Name": "Bob", "Email": "bob@example.com"}
]
Output:
Id,Name,Email
1,Alice,alice@example.com
2,Bob,bob@example.com
CSV → JSON
Rules
| Item | Details |
|---|---|
| Row 1 | Headers |
| Following rows | Values split on commas |
| Output | Pretty-printed JSON array of objects |
| Import | Import CSV from a local file |
Parsing is a simple comma split (fine for typical sheets). Complex quoted/multiline fields: clean in Excel first, or use CSV to Excel.
Steps
- Open CSV to JSON.
- Paste CSV or import a
.csvfile. - Run to get a JSON array.
- Copy into code or config.
Values are strings after conversion—parse numbers in your app if needed.
Common scenarios
| Scenario | Direction |
|---|---|
| API array for business users | JSON → CSV → Excel |
| CSV list → app config | CSV → JSON |
| Load a database | JSON → SQL or Excel to SQL |
| One column only | Convert to CSV, or use JSONPath |
Watch-outs both ways
| Issue | Tip |
|---|---|
| Extra keys on later objects | JSON→CSV uses first object keys only |
| Everything is a string | CSV→JSON does not infer types |
| Nested objects/arrays | Flatten first; CSV is row-oriented |
| Garbled Chinese in Excel | Prefer BOM export; keep source UTF-8 |
Related tools
FAQ
Single object, not an array?
Wrap as [{...}] before JSON→CSV.
Tab separator?
Comma only here; use Text Format afterward if needed.
vs Excel tools?
These tools take text and stay local; Excel tools fit workbook upload and multi-sheet work.