Skip to main content
JSONL.rest logo

JSONL.rest

The definitive resource for JSON Lines format - Your go-to reference for streaming data, AI training, and efficient log processing

Glowing JSON Lines records streaming out of a portal and fanning out to AI, log and analytics destinations

Our Mission

JSONL.rest is the Wikipedia of JSON Lines format - a comprehensive, developer-focused resource that serves as the single source of truth for everything JSONL. Whether you're processing streaming data, training AI models, or managing massive log files, we provide the knowledge and tools you need.

This site isn't just a collection of documentation; it's a living project built from real-world experience. The team at RJL.dev - a group of practicing software engineers and architects - created and actively maintains every piece of content you'll find here. We've navigated the challenges, debugged the tricky edge cases, and optimized the patterns so you can learn from our expertise.

Built by developers, for developers. We believe in making data formats accessible, understandable, and easy to implement. From beginners to experts, JSONL.rest is your trusted companion in the world of newline-delimited JSON.

Validate Your JSONL Data

Check syntax, detect errors, verify schema consistency, and auto-fix common mistakes - all in your browser, 100% private and free.

Open Validator

What This Reference Contains

No vanity metrics here. Every number below is a straight count of the content published on this site, and you can check each one yourself by opening the page it points to.

33

Reference Pages

56

Glossary Terms Defined

14

Parser Errors Decoded

10

Common Mistakes Explained

8

Languages With Code Examples

0

Server Round Trips To Validate

What is JSONL?

Definition

JSON Lines (JSONL), also known as Newline Delimited JSON (NDJSON), is a convenient format for storing structured data that may be processed one record at a time. Each line is a valid JSON value, separated by newline characters.

Core Benefits

  • Streaming iconBuilt for Streaming: Process one line at a time - ideal for data streams or massive files
  • Low memory iconLow Memory Footprint: Handle terabyte files on machines with minimal RAM
  • Append iconEasily Appendable: Add new data by appending a line - no parsing or rewriting required
  • Fault tolerance iconRobust: One corrupted line won't break the entire file

Quick Example

JSON (Traditional)

[
  {"name": "Alice", "age": 30},
  {"name": "Bob", "age": 25},
  {"name": "Charlie", "age": 35}
]

JSONL (Lines)

{"name": "Alice", "age": 30}
{"name": "Bob", "age": 25}
{"name": "Charlie", "age": 35}

Notice: Each line is an independent JSON object - perfect for streaming and processing!

JSON vs JSONL: a JSON array is one bracketed block that must be loaded whole, while JSONL is separate records read one line at a time
The whole difference: one big document, or many small ones.

Specification iconJSONL Quick Facts

Stands forJSON Lines. Also known as NDJSON (Newline Delimited JSON).
File extensions.jsonl and .ndjson
StructureOne JSON value per line, usually an object. No commas between lines, no outer brackets.
EncodingUTF-8
Media typeapplication/x-ndjson or application/jsonl
Best atLarge files, streams, logs and anything that grows by appending
Not ideal forSmall config files and column-heavy analytics, where JSON and Parquet fit better
Read moreThe full definition and specification

Where JSONL Is Used

You have probably used JSONL without choosing it. It is the upload format for AI fine-tuning, the on-disk format for container logs and the wire format for bulk and streaming APIs. Each use below links to a full guide.

Map of JSONL uses: AI training data, application logs, streaming APIs, data pipelines, bulk import and export, analytics events
Six jobs, one format.

Platforms That Read and Write JSONL

OpenAI

Fine-tuning files and Batch API input and output

Amazon Web Services

Bedrock batch inference, Athena tables over S3

Google Cloud

BigQuery load and export, Vertex AI tuning datasets

Microsoft Azure

Azure OpenAI fine-tuning and batch files

Docker

The default json-file container log driver

Elasticsearch

The Bulk API request body

Hugging Face

Dataset files loaded by the datasets library

Apache Spark

The default layout its JSON reader expects

The exact record shape each one expects is on the examples page.

Read and Write JSONL in 60 Seconds

No library is required in any mainstream language. Reading is "for each line, parse JSON". Writing is "serialize, add a newline". The languages page has complete examples for eight languages.

Python

import json

# Read
with open("data.jsonl", encoding="utf-8") as f:
    for line in f:
        record = json.loads(line)

# Write
with open("out.jsonl", "w", encoding="utf-8") as f:
    for record in records:
        f.write(json.dumps(record) + "\n")

JavaScript (Node.js)

import { createReadStream } from 'node:fs';
import { createInterface } from 'node:readline';

const lines = createInterface({
  input: createReadStream('data.jsonl'),
});
for await (const line of lines) {
  const record = JSON.parse(line);
}

Command Line

# How many records?
wc -l data.jsonl

# Show the first one, formatted
head -n 1 data.jsonl | jq .

# Keep only the active users
jq -c 'select(.active)' data.jsonl

# JSON array to JSONL
jq -c '.[]' data.json > data.jsonl

JSONL vs JSON vs CSV vs Parquet

JSONL is not a replacement for every format. It wins when data arrives over time or is too big to hold in memory, and loses when you need a small hand-edited file or fast column scans.

QuestionJSONLJSONCSVParquet
Read one record at a time?YesNo, whole documentYesIn row groups
Append without rewriting?YesNoYesNo
Nested objects and arrays?YesYesNoYes
Data types preserved?JSON typesJSON typesEverything is textFull typed schema
Readable in a text editor?YesYesYesNo, binary
Size on diskLarge, compresses wellLargeSmallSmallest
Best forLogs, streams, AI datasetsConfig, API responsesFlat tables, spreadsheetsAnalytics at scale

Go deeper: JSONL compared with JSON, CSV and XML and the detailed JSONL vs Parquet guide.

JSONL Questions, Answered Briefly

What is a .jsonl file?

A text file in which every line is one complete JSON value, normally an object. It opens in any text editor. To a program it is a list of records that can be read one at a time.

Is JSONL the same as NDJSON?

Yes. JSON Lines and Newline Delimited JSON describe the same bytes. Only the name, the file extension and the suggested media type differ. Renaming data.ndjson to data.jsonl changes nothing.

How do I open a JSONL file?

Any text editor works for small files. For large ones use head or less in a terminal, or paste a sample into the validator to view it as a table.

How do I convert JSON to JSONL?

If the JSON is an array of objects, write each element on its own line: jq -c '.[]' data.json. The conversion guide covers CSV, Parquet and other formats.

Why do AI platforms use JSONL?

A training set is a long list of independent examples. One example per line lets a platform validate, count, shuffle and stream them without loading the file, and report a bad example by its line number.

When should I not use JSONL?

For configuration files, for a single API response, and for analytics over a few columns of a very wide table. JSON reads better for the first two; a columnar format such as Parquet is far faster for the third.

More answers on the full FAQ page.

Ready to Master JSONL?

Explore comprehensive examples, read the specification, and discover when JSONL is the right choice for your project.