Blog

JSONL Explained: What the Line-Delimited JSON Format Is and How to Use It

JSONL is the format you encounter before you know it has a name. It is the JSON you already know, written one record per line instead of wrapped in an array. That small change makes it ideal for streaming, logs, and anything that needs to be appended to without rewriting the whole file.

According to its documentation at jsonlines.org, the format follows three rules: every line is a valid JSON value, lines are separated by `\n` (with `\r` ignored), and the file is UTF-8 encoded.

What happened

  • Stores one JSON value per line rather than a single array.
  • Defined and documented at jsonlines.org.
  • Common in server logs, telemetry streams, and bulk export files.
  • Each line is independently parseable, so you can process records one at a time.
  • In C# with Newtonsoft.Json, you enable `SupportMultipleContent` on `JsonTextReader` and loop with `JsonSerializer.Deserialize`.

What JSONL actually looks like

Regular JSON wraps a list in square brackets, separated by commas:

“`

[

{ "id": 1, "name": "dynamite", "category": "weapon" },

{ "id": 2, "name": "ham", "category": "food" }

]

“`

JSONL drops the brackets and commas. One object per line, newline as the separator:

“`

{"id":1,"name":"dynamite","category":"weapon"}

{"id":2,"name":"ham","category":"food"}

“`

That is the entire difference. No array wrapper, no commas between records, just a newline. The spec at jsonlines.org covers this, and other tools sometimes call it "NDJSON" (Newline Delimited JSON), but the format is the same.

Why the format exists

With a regular JSON array, you must read the entire file before confirming it is well-formed, and you cannot append without parsing and rewriting. With JSONL, each line is self-contained, so you can stream records in or out, and a crashed writer does not corrupt the whole file.

That makes it a natural fit for logs, where each event is appended as a new line and tools can tail the file to process entries as they arrive. The same property shows up in big-data pipelines, machine learning training exports, and any continuous data stream.

How to parse JSONL in C#

Using Newtonsoft.Json, parsing code looks like this. The trick is a flag on the reader: `SupportMultipleContent = true`. Without it, `JsonTextReader` expects a single JSON document and throws on the second line. With the flag enabled, the reader walks across line boundaries and treats each top-level value as a separate document.

A `while (reader.Read())` loop calls `JsonSerializer.Deserialize<T>` on every step. Each call consumes one line and returns one object, which you then add to a list, write to a database, or push to an API.

This pattern comes from a Stack Overflow discussion where developers needed to handle line-separated JSON without wrapping it in an array first.

Our analysis

Regular JSON is friendlier for human-readable config files and one-shot data exchange. JSONL is friendlier for anything that streams, appends, or fails halfway through. The tradeoff is structural: you gain resilience and streaming capability, but you lose the ability to represent nested arrays of values at the top level.

JSON vs. JSONL at a glance

Scenario Better choice Why
Config file, API response, static export JSON Human-readable, complete document
Log file, telemetry, continuous stream JSONL Append-friendly, line-by-line recovery
Mixed: static snapshot plus updates JSONL Append new lines without rewriting
Tool requires strict JSON validation JSON JSONL technically violates array syntax rules

The practical lesson for developers: if a file shows complete `{` objects on every line with no commas or brackets, do not assume it is corrupted. It is probably JSONL. You can rename it, feed it to `jq` with a wrapper, or read it line by line in a script. Converting it to a regular JSON array for one-off use takes seconds: prepend `[`, append `]`, and add commas at the end of every line except the last.

What to watch next: as more AI training pipelines and data export tools default to JSONL, expect broader tool support for the `.jsonl` extension. If you build anything that handles continuous data, this format deserves a place in your toolkit.

Key takeaways

  • JSONL is JSON, one record per line, no array wrapper, no commas between records.
  • It shines for logs, streaming data, and anything append-only.
  • In C# with Newtonsoft, set `SupportMultipleContent = true` on `JsonTextReader` and loop with `Deserialize`.
  • If a "broken" JSON file has a complete object on every line, it is probably JSONL, not corruption.
  • Choose the format that matches your data pattern, not the most popular one.

Frequently asked questions

Is JSONL the same as NDJSON?

Yes. NDJSON stands for "Newline Delimited JSON" and is an alias used by some tools. The jsonlines.org spec covers both names.

Can I convert a regular JSON array to JSONL?

Yes. Drop the surrounding square brackets, drop the commas between objects, and put each object on its own line. The reverse also works: wrap a JSONL file in `[ ]` with commas for tools that require a standard JSON array.

Do I need a special library to parse JSONL?

Not really. Any library that can read one JSON value at a time works, including the Python `json` module with `readlines()`, or `JsonTextReader` with `SupportMultipleContent` enabled in C#.

Where am I most likely to see JSONL in the wild?

Server and application logs, telemetry streams, machine learning training datasets, and bulk data exports. Any place where records are written one at a time rather than as a single batch.

Is JSONL part of the official JSON standard?

No. JSONL is a separate, informal spec maintained at jsonlines.org. It uses JSON syntax per line, but the line-delimited structure itself is not defined in the JSON standard.

Related