JSON to CSV API examples
Choose a language, set TABLECONVERT_API_KEY in your environment, and run the request. Each example saves the CSV response to output.csv.
cURL quickstart
curl --fail-with-body --max-time 40 \
'https://api.tableconvert.com/v2/convert/json-to-csv' \
--header "Authorization: Bearer $TABLECONVERT_API_KEY" \
--form-string 'data=[{"name":"Alice","email":"alice@example.com","active":true},{"name":"Bob","email":"bob@example.com","active":false}]' \
--output output.csvRequires cURL. Use --form-string to send JSON as text; cURL sets the multipart boundary for you.
Python request example
import json
import os
from pathlib import Path
import requests
rows = [
{"name": "Alice", "email": "alice@example.com", "active": True},
{"name": "Bob", "email": "bob@example.com", "active": False},
]
response = requests.post(
"https://api.tableconvert.com/v2/convert/json-to-csv",
headers={
"Authorization": f"Bearer {os.environ['TABLECONVERT_API_KEY']}"
},
files={"data": (None, json.dumps(rows))},
timeout=40,
)
response.raise_for_status()
Path("output.csv").write_bytes(response.content)Requires Python 3 and the requests package: pip install requests.
Node.js request example
import { writeFile } from "node:fs/promises";
const rows = [
{ name: "Alice", email: "alice@example.com", active: true },
{ name: "Bob", email: "bob@example.com", active: false },
];
const form = new FormData();
form.set("data", JSON.stringify(rows));
const response = await fetch(
"https://api.tableconvert.com/v2/convert/json-to-csv",
{
method: "POST",
headers: {
Authorization: "Bearer " + process.env.TABLECONVERT_API_KEY,
},
body: form,
signal: AbortSignal.timeout(40_000),
},
);
if (!response.ok) {
throw new Error("HTTP " + response.status + ": " + await response.text());
}
await writeFile("output.csv", Buffer.from(await response.arrayBuffer()));Uses the built-in fetch and FormData APIs in Node.js 20 or later.
Authentication and response
Send your API key in the Authorization: Bearer header. For a successful v2 request, the response body is CSV text, not a JSON envelope or a download URL.
Keep API keys in server-side environment variables in production. Never put a key in a public repository or a URL.
Request parameters
Send multipart/form-data. Choose one input source: data, file or url. Do not manually set the Content-Type header; your HTTP client adds the multipart boundary.
| Parameter | Type | Description |
|---|---|---|
data | string | JSON text. A nonempty array of flat objects is the clearest way to send records. |
file | binary | A .json file upload. Use file=@records.json with cURL. |
url | string | A public HTTP or HTTPS URL to a JSON file. |
One input required
CSV output options
Add these optional form fields to control the CSV output. The defaults below match this page’s sample.
| Parameter | Default | Description |
|---|---|---|
output[doubleQuote]boolean | true | Wrap every field in double quotes. Embedded quotes are not doubled automatically; normalize those values before conversion. |
output[bom]boolean | false | Prefix the output with a UTF-8 byte order mark, useful for some Excel import workflows. |
output[valueDelimiter]string | , | Separate columns with a comma, semicolon or TAB. |
output[rowDelimiter]string | NEWLINE | Separate rows. NEWLINE produces CRLF line endings. |
output[prefix]string | Empty string | Text prepended to each row. |
output[suffix]string | Empty string | Text appended to each row. |
Nested JSON and field mapping
This endpoint converts tabular records. Check these mapping rules before exporting data from an API, database or application.
| Input | CSV behavior |
|---|---|
| Different object keys | Columns use the union of all keys, in the order each key first appears. |
| Missing field | An empty CSV cell. |
| null | The text null; it is not an empty cell. |
| Numbers and booleans | Converted to text, for example 42, true and false. |
| Nested object | Not flattened. The cell becomes [object Object]. Prepare flat records before sending. |
| Array inside a field | Not expanded into rows. Its values become a comma-separated string. |
| Double quotes inside a value | Internal quotes are not escaped automatically. Normalize or remove them before exporting. |
Need columns from nested JSON?
Prepare the fields you want before making the request. This example turns profile.city into a city column; it does not require a flatten API parameter.
const records = [
{ name: "Alice", profile: { city: "London" } },
];
const rows = records.map(({ name, profile }) => ({
name,
city: profile.city,
}));
// Send JSON.stringify(rows) in the data form field.Responses and errors
Check the HTTP status before saving the response. Successful v2 responses use text/plain; error bodies contain a plain-text message.
| Status | Meaning | What to check |
|---|---|---|
200 | text/plain; charset=utf-8 | CSV response |
400 | Missing API key or unsupported request | Add the Bearer header and check your input fields. |
403 | Invalid API key | Check the key in your account. |
402 | Insufficient credits | Review your balance or plan before retrying. |
413 | Input too large | Check the upload and text-field limits below. |
415 | Unsupported request encoding | Send the documented multipart/form-data request. |
429 | Too many requests | Wait before retrying; avoid immediate retry loops. |
500 | JSON parsing or conversion failed | Validate the JSON and send a nonempty array of records. |
503 | Conversion timed out or service unavailable | Try a smaller input or retry later. |
Limits and usage
File uploads support up to 50 MiB (52,428,800 bytes). An individual multipart text field is limited to 1 MiB; use file upload for larger JSON. The v2 processing deadline is 30 seconds.
A successful standard JSON to CSV conversion uses 1 credit. Failed or timed-out conversions release the reserved credit. Legacy account terms may differ; check your account and current pricing.
View API pricingUsing the original API?
This page documents v2, which returns CSV directly. The original /convert/json-to-csv endpoint returns a JSON envelope. Keep the response handling that matches your API version.
API overviewQuestions before you integrate
Does this API automatically flatten nested JSON?
No. Flatten nested objects into the columns you need before sending records. The mapping table and preparation example above describe the current behavior.
How do I upload a JSON file instead of pasting data?
Use the file form field and omit data. With cURL, replace --form-string 'data=…' with --form 'file=@records.json;type=application/json'.
How do I create a semicolon-delimited CSV for Excel?
Add output[valueDelimiter]=; to the multipart form. If your Excel import workflow needs a UTF-8 BOM, also set output[bom]=true.
Can I try the example without an API key?
Yes. Preview sample runs the flat-record example in your browser without an API call. Sending a live request requires your key and follows normal API billing.