CSV to JSON API
Convert CSV into an array of JSON objects using the header row, with delimiter auto-detection, number and boolean typing, and row-level errors.
Send CSV text in the csv field or as a raw text/csv / text/plain body. By default the first row is used as header and each following row becomes an object (rows), with fields listing the column names. Set header=false to get arrays of values instead.
The delimiter (comma, semicolon, tab, pipe...) is detected automatically, or forced with delimiter. Numbers and booleans are converted to JSON types (dynamic_typing, on by default); set dynamic_typing=false to keep every value as a string. Quoted fields with commas and line breaks are handled, and empty lines are skipped.
The response also includes row_count, the delimiter used and up to 50 parse errors (row, message, code), such as rows with too few fields. The request body is limited to 5 MB.
Parameters
| Name | In | Type | Required | Default | |
|---|---|---|---|---|---|
csv | body | string | yes | CSV text. Can also be sent as a raw text/csv or text/plain body. | |
header | body|query | boolean | no | true | Use the first row as column names and return objects. |
delimiter | body|query | string | no | Field delimiter; auto-detected when empty. | |
dynamic_typing | body|query | boolean | no | true | Convert numbers and booleans to JSON types. |
Example
curl -X POST "https://apibox.io.vn/v1/csv-to-json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"csv":"name,age,city\nAlice,30,Hanoi\nBob,25,\"Ho Chi Minh City\""}'const res = await fetch('https://apibox.io.vn/v1/csv-to-json', {
method: 'POST',
headers: {
Authorization: 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"csv": "name,age,city\nAlice,30,Hanoi\nBob,25,\"Ho Chi Minh City\""
}),
});
const data = await res.json();
console.log(data);import requests
res = requests.post(
"https://apibox.io.vn/v1/csv-to-json",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={"csv": "name,age,city\nAlice,30,Hanoi\nBob,25,\"Ho Chi Minh City\""},
timeout=30,
)
print(res.json())<?php
$ch = curl_init('https://apibox.io.vn/v1/csv-to-json');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => ['Authorization: Bearer YOUR_API_KEY', 'Content-Type: application/json'],
CURLOPT_POSTFIELDS => '{"csv":"name,age,city\\nAlice,30,Hanoi\\nBob,25,\\"Ho Chi Minh City\\""}',
]);
$response = curl_exec($ch);
print_r(json_decode($response, true));Response
{
"rows": [
{
"name": "Alice",
"age": 30,
"city": "Hanoi"
},
{
"name": "Bob",
"age": 25,
"city": "Ho Chi Minh City"
}
],
"row_count": 2,
"fields": [
"name",
"age",
"city"
],
"delimiter": ",",
"errors": []
}
Use cases
- Import spreadsheet exports (Excel, Google Sheets) into an app
- Turn CSV reports into JSON for a frontend or chart library
- Load CSV seed data into a NoSQL database
- Validate CSV uploads and report broken rows to users
FAQ
Is the delimiter detected automatically?
Yes. Comma, semicolon, tab and other common delimiters are detected; use delimiter to force one.
Are numbers converted or kept as strings?
Numbers and booleans are converted by default. Send dynamic_typing=false to keep all values as strings (useful for zip codes or IDs with leading zeros).
What if my CSV has no header row?
Set header=false; each row is then returned as an array and fields is null.
Related APIs
JSON Validator
Check JSON syntax with exact line and column of errors, and validate data against a JSON Schema (draft 4, 7, 2019-09 or 2020-12).
{ }JSON Formatter
Pretty print JSON with 0-8 spaces or tabs, minify it, or sort object keys recursively. Syntax errors are reported with line and column.
J→CJSON to CSV
Convert a JSON array of objects or arrays into CSV with a header row and a custom delimiter, returned as JSON or as a downloadable text/csv file.