About the JSON to JSON Lines
Convert a JSON array to JSON Lines (one compact object per line), the format used by BigQuery, log pipelines and ML datasets. It also converts back.
Key features
- JSON array → JSON Lines (one object per line)
- JSON Lines → JSON array
- Reports the exact line number of invalid records
- Skips blank lines when reading JSONL
- Compatible with NDJSON and JSONL tools
- Download as a .jsonl file
What is JSON Lines?
JSON Lines (JSONL, also called NDJSON) stores one JSON value per line:
{"id":1,"name":"Laptop"}
{"id":2,"name":"Mouse"}
{"id":3,"name":"Desk Lamp"}
A regular JSON array of the same data:
[
{ "id": 1, "name": "Laptop" },
{ "id": 2, "name": "Mouse" },
{ "id": 3, "name": "Desk Lamp" }
]
This tool converts between the two in either direction.
Why JSON Lines?
| JSON array | JSON Lines | |
|---|---|---|
| Streamable | ❌ must read the whole file | ✅ line by line |
| Append a record | ❌ rewrite the closing ] | ✅ append a line |
| Huge files (GBs) | ❌ memory-heavy | ✅ constant memory |
| Partial corruption | ❌ whole file invalid | ✅ only one line lost |
| Parallel processing | ⚠️ hard | ✅ split by lines |
Where JSON Lines is used
- Machine learning: OpenAI fine-tuning and batch files, Hugging Face datasets.
- Data warehouses: BigQuery, Snowflake, Redshift and DuckDB loads.
- Search: Elasticsearch/OpenSearch
_bulkrequests. - Logging: structured logs, one event per line.
- Command line:
jq -c '.[]'turns an array into JSONL.
Example: preparing a fine-tuning file
[
{ "messages": [ { "role": "user", "content": "Hi" }, { "role": "assistant", "content": "Hello!" } ] }
]
Convert to JSONL and each conversation becomes one line, exactly the format fine-tuning APIs expect.
Related tools
To compact a single document, use JSON to One Line. To check an individual record, paste it into the JSON Validator.
How to use the JSON to JSON Lines
- Paste your data into the input box, upload a file, or click Sample to try it out.
- Adjust the options above the editor if you need to (indentation, delimiter, and so on).
- The JSON Lines appears instantly in the output panel. Any errors are shown with their line and column.
- Click Copy to copy the result, or Download to save it as a file.