Xerobit

JSONL to CSV Converter

Use this jsonl to csv converter to turn JSON Lines data into properly quoted CSV. It builds a header row from the union of all keys in first-seen order, handles nested objects and arrays, and lets you choose a delimiter or flatten dot paths. The conversion runs entirely in your browser, so nothing is uploaded.

Turns {"a":{"b":1}} into column "a.b" instead of a JSON string.

CSV output

name,age,city
Alice,30,
Bob,,NYC

How to use the jsonl to csv converter

  1. Paste your JSONL or NDJSON text into the input area, one JSON object per line.
  2. Choose a delimiter: comma for standard CSV, tab for TSV, semicolon or pipe if your data contains many commas.
  3. Check Flatten nested objects if you want dot-separated column names like user.name instead of compact JSON strings.
  4. The CSV output updates live as you type. Copy it directly from the result box.

How the jsonl to csv conversion works

A JSONL file contains one JSON object per line. To produce valid CSV, the converter reads every line, parses it as JSON, and collects all top-level keys in the order they first appear. This ordered union becomes the header row.

Each subsequent row maps the object's values to those columns. Missing keys produce empty fields. For example, given two lines {"id":1,"color":"red"} and {"id":2,"size":"large"}, the header is id,color,size and the rows are 1,red, and 2,,large.

Values that contain the chosen delimiter, double quotes or newlines are wrapped in double quotes per RFC 4180. Any double quote inside a value is escaped by doubling it. Primitive values (strings, numbers, booleans, null) are written directly. Arrays and objects are serialized as compact JSON strings unless flattening is enabled.

Flattening nested objects

When the flatten option is on, nested objects are expanded into separate columns using dot notation. A record like {"user":{"name":"Alice","role":"admin"}} produces columns user.name and user.role. This is useful when importing into spreadsheets or databases that expect flat tables.

Arrays are not flattened because their variable length would create unpredictable column counts. They remain as compact JSON strings even when flattening is active. Deeply nested objects are flattened recursively: {"a":{"b":{"c":1}}} becomes column a.b.c with value 1.

RFC 4180 quoting rules

The output follows RFC 4180, the standard format for CSV files. The rules are straightforward:

  • Fields containing the delimiter character, a double quote or a line break must be enclosed in double quotes.
  • A double quote appearing inside a field is escaped by preceding it with another double quote. For example, the value say "hi" becomes "say ""hi""".
  • Line endings between records use CRLF (\r\n), though most modern tools accept LF alone.

These rules ensure that the generated CSV can be opened reliably in Excel, LibreOffice Calc, Python's csv module or any database import tool without data corruption.

Common edge cases

Empty lines in the input are silently skipped, which is common in files with trailing newlines. If a line is not valid JSON, the converter stops and reports the offending line number so you can fix the source data.

Non-object JSON values (bare strings, numbers, arrays or nulls at the top level) are rejected because CSV requires named columns. Each line must parse to a JSON object.

Very large inputs may take a moment to process since parsing happens synchronously in the browser. For files over a few megabytes, consider splitting them first or using a command-line tool like jq alongside a scripting language.

Worked examples

ExampleInputResult
Simple recordsJSONL input: {"name":"Alice","age":30} / {"name":"Bob","age":25}; Delimiter: ,; Flatten nested objects with dot paths: noname,age / Alice,30 / Bob,25
Union of keysJSONL input: {"id":1,"color":"red"} / {"id":2,"size":"large"}; Delimiter: ,; Flatten nested objects with dot paths: noid,color,size / 1,red, / 2,,large
Flatten nested objectsJSONL input: {"user":{"name":"A","role":"admin"}} / {"user":{"name":"B"}}; Delimiter: ,; Flatten nested objects with dot paths: yesuser.name,user.role / A,admin / B,
Tab-separated outputJSONL input: {"a":1,"b":"hello, world"} / {"a":2,"b":"line\nbreak"}; Delimiter: ; Flatten nested objects with dot paths: noa b / 1 hello, world / 2 "line / break"

FAQ

What is JSONL?

JSONL (JSON Lines) is a text format where each line is a self-contained JSON value, typically an object. It is also called NDJSON (Newline Delimited JSON) and is widely used for log files, streaming APIs and bulk data imports.

Does this jsonl to csv tool upload my data?

No. The conversion runs entirely in your browser using JavaScript. Nothing is sent to any server.

How are nested objects handled?

By default, nested objects and arrays are serialized as compact JSON strings within a single CSV cell. If you enable the flatten option, nested objects are expanded into separate columns using dot-separated paths like user.address.city.

Can I use a tab delimiter instead of a comma?

Yes. Select Tab (TSV) from the delimiter dropdown to produce tab-separated output. Semicolon and pipe delimiters are also available for data that contains many commas.

Why does my output have double quotes around some fields?

Fields that contain the delimiter, double quotes or newline characters are wrapped in double quotes according to RFC 4180. Any literal double quote inside the field is escaped by doubling it.

What happens if a key is missing in some records?

The header includes the union of all keys across every record. When a particular record lacks a key, the corresponding CSV field is left empty.

Is there a limit on file size?

There is no hard limit, but very large inputs may slow down your browser tab since parsing is done in memory. For multi-megabyte files, consider splitting the data first.