Format Atlas

Compare

JSON Lines vs JSON

JSON Lines (newline-delimited JSON) is a UTF-8 text convention that places one independent valid JSON value on each line. A regular JSON text represents one value as a whole, so JSON Lines suits sequential processing and appending multiple records.

Which format should you choose?

Consider JSON Lines for logs or events processed and appended one record at a time. Use regular JSON for a single configuration document or a complete nested object or array.

Good fit for JSON Lines

Logs and records processed line by line · Streaming exchange of JSON records

  • Reading and writing records incrementally
  • Appending or combining text data with common tools

Good fit for JSON

Web APIs, configuration files, and data exchange

  • Transferring structured data

Basic information

FieldJSON LinesJSON
Extension.jsonl, .ndjson.json
MIME typeapplication/jsonlapplication/json
Common usesLogs and records processed line by line · Streaming exchange of JSON recordsWeb APIs, configuration files, and data exchange
How to openOpen the file in a text editor or a JSON Lines-aware tool. Validating each line as JSON makes it easier to identify the record containing a syntax error.Open it in a text editor, IDE, or JSON-aware viewer.
Export or convertTo create a JSON array, collect the lines as array elements. To convert an array to JSON Lines, write each value on its own line. For large files, consider memory use during conversion.Applications or conversion tools can convert it to formats such as CSV.

Choose by use case

Reading and writing records incrementally

Logs and records processed line by line · Streaming exchange of JSON records

JSON Lines

Appending or combining text data with common tools

Logs and records processed line by line · Streaming exchange of JSON records

JSON Lines

Transferring structured data

Web APIs, configuration files, and data exchange

JSON

Key point 1

Each JSON Lines line must parse as one JSON value. Objects are common, but strings, numbers, null, and other JSON values are permitted; a blank line is not a record. A regular JSON text represents one value overall.

More on the differences

Key point 2

JSON Lines uses UTF-8 and LF between values; CRLF is also supported as JSON whitespace. A final newline is recommended but not required, so consumers should define how to handle concatenation and stream boundaries.

More on the differences

More on the differences

Use JSON Lines for record-at-a-time pipelines and append-friendly logs, provided the receiver supports it. Use JSON for a single structured document. Parse JSON Lines line by line; do not assume a whole JSONL file is one standard JSON document.

  • A JSON Lines file contains multiple top-level JSON values separated by line endings, so a typical JSON document parser may reject the file when given as a whole.
  • Define behavior for ordering, blank or malformed lines, recovery after a bad record, and whether the last line needs a terminator.
  • JSON Lines uses UTF-8 and excludes a BOM. The suggested `application/jsonl` media type is not standardized; agree on transport metadata with consumers.

Frequently asked questions

Is a JSON Lines file just a JSON array?

No. It is a sequence of JSON values separated by line endings, not a single JSON array document. Each line can be processed independently.

Learn more

References and specifications