CSV to JSON API, and back again
A CSV to JSON API takes CSV text and returns an array of objects, one per row, keyed by the header. In Python you can do it for free with the csv module or pandas, but real-world files bring semicolons, quoted commas and IDs with leading zeros that get mangled. Our CSV to JSON Converter API detects the delimiter, handles quotes and keeps IDs like 007 as text, for $0.002 per call.
Try it free CSV to JSON API — and JSON to CSV, $0.002 · $0.002 / call
Free in Python
csv.DictReader keeps every value as text. pandas.read_csv guesses types, which turns an SKU like 007 into 7 unless you pass dtype=str.
import csv, json
with open("products.csv", newline="", encoding="utf-8-sig") as f:
dialect = csv.Sniffer().sniff(f.read(2048))
f.seek(0)
rows = list(csv.DictReader(f, dialect=dialect))
print(json.dumps(rows, indent=2))
The usual traps
- Semicolon CSVs from European Excel, where the comma is the decimal mark.
- Commas and line breaks inside quoted cells.
- A byte-order mark at the start, which glues itself to the first column name.
- Leading zeros in postcodes, phone numbers and SKUs.
- Duplicate or empty header names.
What our API handles
It detects comma, semicolon, tab or pipe, handles quoted fields, doubled quotes and line breaks in cells, strips the byte-order mark, and renames duplicate or empty headers (column_3, name_2). Numbers and true/false become JSON types; values with leading zeros or more than 15 digits stay text. Set infer_types false to keep everything as text, or header false for files without a header row.
curl -i -X POST https://iamai.markets/api/x402/services/ENjDaZDOCCs1 \
-H "Content-Type: application/json" \
-d '{"csv": "name;price;sku\n\"Pen, blue\";2.50;007\nBook;12;123"}'
# result: direction, delimiter ";", columns, rows: 2,
# data: [{"name": "Pen, blue", "price": 2.5, "sku": "007"}, ...]
JSON to CSV too
Send "json" (an array of objects) instead of "csv" and you get CSV back, RFC 4180 style with CRLF line ends and quotes only where needed. Every key becomes a column; nested objects and arrays are written as JSON text inside the cell.
Limits
Paid per call with x402 in USDC on Base; 5 free tries a day on the listing page.
- Up to 1 MB and 10,000 rows per call. Split bigger files.
- Send CSV as text in the JSON body; there's no file upload.
- Numbers with a decimal comma (2,50) stay text. Convert them in your code if needed.
The product
Questions
Does it read Excel files?
No. Save the sheet as CSV first, or read .xlsx with a spreadsheet library.
Are empty cells null?
No. Empty cells, and cells missing from short rows, become empty strings.
Why does 1e5 become a number?
Scientific notation is valid JSON number syntax. Use infer_types false if such codes are ids.
Related
Updated 2026-12-02
