JSON to CSV Converter - Convert JSON Arrays to CSV Online
Convert between JSON arrays and CSV/TSV formats with nested object flattening. Preview data in table format and customize delimiters.
Frequently Asked Questions
What is a JSON to CSV converter?
A JSON to CSV converter is a tool that transforms JSON (JavaScript Object Notation) data into CSV (Comma-Separated Values) or TSV (Tab-Separated Values) tabular format, and vice versa. JSON stores data as nested objects and arrays, while CSV represents data in rows and columns separated by a delimiter character. Developers and data analysts frequently need to convert between these formats when exporting API responses to spreadsheets, importing CSV data into JSON-based applications, or migrating data between systems. This converter handles nested objects by flattening them into dot-notation column headers (e.g., user.address.city) and properly escapes special characters following RFC 4180.
How do I use this JSON to CSV converter?
1. Select your conversion direction using the tabs: JSON to CSV or CSV to JSON. 2. Paste your data into the input area or upload a file using the Upload button. 3. The conversion happens automatically in real-time as you type. 4. For JSON to CSV: choose your delimiter (Comma, Tab, or Semicolon) and toggle options like Include header row and Flatten nested objects. 5. For CSV to JSON: the delimiter is auto-detected, or you can select it manually. Toggle First row is header and Auto-detect types as needed. 6. Review the output in the output panel and the visual preview table below it. 7. Click the Copy button to copy the result or Download to save as a file.
Is my data safe? Does it get sent to a server?
Your data is 100% safe and never leaves your browser. This converter runs entirely in client-side JavaScript — no data is transmitted to any server, stored in any database, or logged anywhere. All parsing, flattening, escaping, and conversion happens locally on your device using native browser APIs. You can verify this by disconnecting from the internet: the tool works fully offline after the initial page load. This makes it safe for converting sensitive API responses, database exports, credentials, and proprietary datasets.
How does the converter handle nested JSON objects?
Nested JSON objects are flattened using dot-notation column headers. For example, {"user": {"name": "Alice", "address": {"city": "Seoul"}}} produces columns named user.name and user.address.city. Arrays within objects can be handled in two ways: (1) Stringify mode converts arrays to JSON strings in cells (e.g., ["tag1","tag2"]), or (2) Expand mode creates a separate row for each array element. The Flatten nested objects toggle controls whether nested objects are flattened into dot-notation columns or stringified as JSON. All objects in the array are analyzed to produce a complete set of column headers, with empty cells for properties missing in individual objects.
What CSV/TSV format does this tool produce?
The tool produces RFC 4180 compliant CSV output. This means: fields containing the delimiter character, double quotes, or newlines are automatically enclosed in double quotes; double quotes within field values are escaped by doubling them; the first row contains column headers by default (configurable); and rows are separated by newline characters. For TSV output, tab characters are used as delimiters instead of commas. The output uses UTF-8 encoding.
What should I do if my JSON data is not an array?
This converter expects a JSON array of objects as input (e.g., [{"name": "Alice"}, {"name": "Bob"}]). If your input is a single JSON object, the converter will automatically wrap it into a single-element array and convert it. If your data is nested and the array is inside a property (e.g., {"data": {"results": [...]}}), you will need to extract the array portion first.
How do I convert CSV back to JSON with nested objects?
When converting CSV to JSON, the converter produces a flat JSON array of objects by default, where each column header becomes a key and each row becomes an object. Type inference is supported: numeric strings become numbers, true/false become booleans, and null becomes null. If you need all values as strings, disable the Auto-detect types option.
Code Examples
// JSON Array to CSV Converter (Client-side, no dependencies)
function flattenObject(obj, prefix = "") {
const result = {};
for (const [key, value] of Object.entries(obj)) {
const fullKey = prefix ? `${prefix}.${key}` : key;
if (value !== null && typeof value === "object" && !Array.isArray(value)) {
Object.assign(result, flattenObject(value, fullKey));
} else {
result[fullKey] = value;
}
}
return result;
}
function escapeField(value, delimiter = ",") {
if (value === null || value === undefined) return "";
const str = typeof value === "object" ? JSON.stringify(value) : String(value);
if (str.includes(delimiter) || str.includes('"') || str.includes("\n")) {
return `"${str.replace(/"/g, '""')}"`;
}
return str;
}
function jsonToCsv(jsonArray, options = {}) {
const { delimiter = ",", includeHeader = true, flatten = true } = options;
const rows = flatten ? jsonArray.map(item => flattenObject(item)) : jsonArray;
const headerSet = new Set();
rows.forEach(row => Object.keys(row).forEach(key => headerSet.add(key)));
const headers = Array.from(headerSet);
const lines = [];
if (includeHeader) {
lines.push(headers.map(h => escapeField(h, delimiter)).join(delimiter));
}
for (const row of rows) {
lines.push(headers.map(h => escapeField(row[h], delimiter)).join(delimiter));
}
return lines.join("\n");
}
// Example usage
const data = [
{ name: "Alice", age: 30, address: { city: "Seoul" } },
{ name: "Bob", age: 25, address: { city: "Tokyo" } }
];
console.log(jsonToCsv(data));
// name,age,address.city
// Alice,30,Seoul
// Bob,25,Tokyo