JSON to CSV Converter transforms JSON arrays of objects into CSV (comma-separated values) format for use in spreadsheets, data analysis tools, and databases. Paste a JSON array and get properly formatted CSV with headers derived from the JSON keys, values correctly escaped (strings with commas quoted, quotes doubled), and options to configure the delimiter, line ending, and BOM.
CSV (Comma-Separated Values) is a plain-text tabular data format used by Excel, Google Sheets, R, pandas, and most data tools. Each line is a row; commas separate columns; the first row is typically headers. RFC 4180 (2005) is the informal CSV standard: fields with commas, double-quotes, or newlines must be enclosed in double-quotes; double-quotes within fields are escaped as two consecutive quotes (""). Tab-separated values (TSV) use tabs as delimiters β safer for data containing commas.
JSON to CSV conversion has edge cases: nested objects (do you flatten them or stringify them?), arrays within objects (expand to multiple rows or join as a string?), missing keys (some objects don't have all keys β output empty cell or skip?), and null values (output as empty string, 'null', or skip?). This tool handles these by flattening nested objects with dot-notation keys (address.city becomes a column header) and stringifying arrays.
Simple array to CSV
Result: [{name:'Alice',age:30},{name:'Bob',age:25}] β name,age\nAlice,30\nBob,25
Handle nested object
Result: {user:{name:'Alice'},score:95} β user.name,score\nAlice,95
Value with comma
Result: {city:'Portland, OR'} β city\n"Portland, OR" (quoted automatically)
Why do I need to quote CSV fields with commas?
In CSV, the comma is the field delimiter. If a field value contains a comma, it must be wrapped in double quotes to prevent the CSV parser from treating the comma as a column separator. Per RFC 4180: a field that contains commas, newlines, or double-quote characters must be enclosed in double-quote characters. A double-quote within a quoted field is escaped by preceding it with another double-quote. Example: 'Portland, OR' β '"Portland, OR"' in CSV. Failing to quote properly causes CSV parsers to split the field into multiple columns.
What is a BOM and when should I include it in CSV?
BOM (Byte Order Mark) is a Unicode character (U+FEFF) placed at the start of a text file to indicate the encoding. UTF-8 BOM: EF BB BF as the first 3 bytes. Microsoft Excel on Windows uses the BOM to detect UTF-8 CSV files β without the BOM, Excel often misinterprets non-ASCII characters (accented letters, CJK characters) using the system's default encoding (often Windows-1252), garbling the data. If your CSV will be opened by Excel users: include the BOM. For CSV consumed by programming languages or servers: omit the BOM (BOM can break parsing in some tools).
How should I handle nested JSON when converting to CSV?
Options for nested JSON: (1) Flatten with dot notation: {'user': {'name': 'Alice', 'age': 30}} β 'user.name', 'user.age' columns. Most tools support this. (2) JSON stringify: serialize the nested value as a JSON string in the cell: "{'name': 'Alice', 'age': 30}". Less useful for analysis. (3) Expand arrays into multiple rows: [{'name': 'Alice', 'tags': ['admin', 'user']}] β two rows, one per tag. For deep nesting, flattening is usually best. Tools like pandas (Python) and jq can handle complex transformations.
How do I convert CSV back to JSON?
JavaScript: Papa.parse (papaparse.com) is the best client-side CSV parser β handles BOM, edge cases, type inference. Python: import csv; rows = list(csv.DictReader(open('file.csv'))) β gives a list of dictionaries. pandas: df = pd.read_csv('file.csv'); df.to_json('output.json', orient='records'). Command line: csvkit's csvjson command. Each row in the CSV becomes an object in the JSON array, with column headers as keys. Type inference: CSV has no types (everything is a string) β parsers may infer numbers and booleans, or you handle it in code.
What delimiter should I use for CSV files?
Comma (,): the RFC 4180 standard and most common. Use for: Excel, Google Sheets, most tools. Semicolon (;): common in European locales where the comma is used as the decimal separator. Excel auto-detects based on system locale. Tab (\t): TSV format β safer when data contains commas. Import into Excel/Sheets as a TSV file. Pipe (|): sometimes used in data pipelines where both commas and semicolons appear in data. For maximum compatibility: comma delimiter with proper quoting (RFC 4180). For European targets: test with semicolon or use UTF-8 BOM to help Excel detect the file.