A CSV file keeps data in rows and columns. A JSONL file keeps one JSON object on each line. This CSV to JSONL converter changes each CSV row into a separate JSON object. You can use JSONL files in scripts, APIs, machine learning datasets, logs and data workflows.
Convert CSV to JSONL
Paste CSV data into the box above, or click Upload file to open a .csv file. The tool uses the first CSV row as the keys of each object. The JSONL shows immediately.
CSV input:
id,name,email
1,Ana,[email protected]
2,Luis,[email protected]
JSONL output (default settings):
{"id":1,"name":"Ana","email":"[email protected]"}
{"id":2,"name":"Luis","email":"[email protected]"}
The option Detect numbers & true/false is on by default. With this option, the tool changes numbers into JSON numbers and true or false into JSON booleans. Values with a leading zero, such as 007, stay text. If you turn off the option, all values are text:
{"id":"1","name":"Ana","email":"[email protected]"}
{"id":"2","name":"Luis","email":"[email protected]"}
Empty cells become empty text (""). To get null for empty cells, turn on Empty cells as null in More options.
What Is JSONL?
JSONL is a text format with one valid JSON value on each line. Each line is usually one object, and each object is one record. Other names for JSONL are JSON Lines and NDJSON (newline-delimited JSON). The three names identify the same format.
A standard JSON file usually keeps all records in one array. A JSONL file has no array and no commas between records.
JSON array:
[
{ "id": 1, "name": "Ana" },
{ "id": 2, "name": "Luis" }
]
JSONL:
{"id":1,"name":"Ana"}
{"id":2,"name":"Luis"}
JSONL vs JSON
| Feature | JSON | JSONL |
|---|---|---|
| Structure | Usually one object or one array | One JSON value on each line |
| Processing | The program must usually read all of the file | The program can read one line at a time |
| Best for | APIs and configuration | Data pipelines, logs and large datasets |
| Readability | Nested structures are easy to show | Each record is separate |
| File format | Usually .json | Usually .jsonl or .ndjson |
If you need a JSON array, open More options and set Output to JSON array.
How to Convert CSV to JSONL
- Paste CSV data that has a header row.
- Make sure that each row has the correct number of columns.
- Examine the JSONL output. The tool converts the data while you type.
- Make sure that each line has the correct JSON object.
- Click Copy JSONL or Download .jsonl.
CSV Formatting Rules to Check First
- Put the column names in the first row.
- Use the same column order in each row.
- Put quotation marks around values that contain a comma.
- Write a quotation mark inside a value as two quotation marks (
""). - Examine blank values before you convert the file.
- Put quotation marks around a value that contains a line break. Then the line break stays in the value.
id,description
1,"A product with a comma, included in the description"
The tool finds the delimiter automatically. It reads comma, semicolon, tab and pipe files. The badge above the result shows the delimiter, the number of rows and the number of columns.
CSV to JSONL Use Cases
- Import records into Python or JavaScript scripts.
- Prepare data for machine learning, for example fine-tuning datasets.
- Process log records one line at a time.
- Send records to systems that keep one document for each record, for example Elasticsearch.
- Make newline-delimited datasets for tools such as BigQuery.
- Move spreadsheet data into developer tools.
- Prepare bulk data for APIs that accept JSONL.
Common CSV to JSONL Errors
- Missing header row. Without a header row, the tool uses the first data row as keys. Turn off First row is header to get keys such as
col_1andcol_2. - Duplicate column names. JSON keys must be unique. The tool adds
_2,_3to the duplicate names and shows a message. - Inconsistent column counts. If a row has fewer cells, the missing values are empty. If a row has more cells, the extra values get keys such as
col_5. The tool shows the number of these rows. - Unescaped quotation marks. A single
"inside a value can join two cells. Write it as""inside a quoted value. - Commas inside unquoted values. A comma without quotation marks starts a new column. Put quotation marks around the value.
- Invalid line breaks. A line break outside quotation marks starts a new row.
- Empty records. By default, the tool skips empty rows. To keep them, turn off Skip empty rows.
- Incorrect type assumptions. A ZIP code such as
10115becomes a number. If you need text, turn off Detect numbers & true/false. - Invalid JSON caused by unsupported characters. The tool writes valid JSON for all characters, including accents and emoji. It does not change accented letters into
\ucodes.
Convert CSV to JSONL with code
Python (standard library):
import csv, json
with open("data.csv", newline="", encoding="utf-8") as src, open("data.jsonl", "w", encoding="utf-8") as out:
for row in csv.DictReader(src):
out.write(json.dumps(row, ensure_ascii=False) + "\n")
This code writes all values as text.
pandas:
import pandas as pd
df = pd.read_csv("data.csv")
df.to_json("data.jsonl", orient="records", lines=True, force_ascii=False)
Command line with Miller:
mlr --icsv --ojsonl cat data.csv > data.jsonl
Related Data Conversion Tools
- Markdown to CSV: change a Markdown table into CSV first.
- Convert table to Markdown: change CSV data into a Markdown table.
- CSV Cleaner & Validator: find and fix problems in a CSV file before you convert it.
- JSON to TypeScript: make TypeScript types from one of the JSON objects.
The converter works in your browser. Your CSV does not go to a server.
Convert your CSV rows into line-by-line JSON objects for your next data workflow.