Shard Tools

JSON to JSONL

Turn a JSON array into JSON Lines in your browser, one record per line, ready for streaming tools.

Maintained by Roshan.

Use JSON to JSONL

Converts JSON array into JSON Lines in this tab. Configuration files routinely hold hostnames, keys and credentials, so nothing here is sent anywhere.

Values are never retyped as numbers or booleansGuessing types is how a converter turns a postcode of 0123 into 123, or a literal string of false into a boolean. Values are carried across as they were written, and casting is left to you where it matters.

Explore developer and data tools

Find related browser-local tools for nearby tasks without starting another search.

Browse all developer and data tools

About JSON to JSONL

JSON Lines exists because a single enormous JSON array is awkward to process. To read one record you have to parse the whole file, which means holding all of it in memory, and a file that grows past what a machine can hold becomes unusable rather than merely slow. JSON Lines solves this by putting one complete JSON value on each line, so a program can read a line, process it, and forget it. That is why it has become the standard format for log shipping, machine learning datasets, database bulk import and anything else that streams. The conversion is mechanical but has one hard rule: no record may contain a literal newline, because the newline is the delimiter. Every record here is written compactly for exactly that reason.

Work through the input

  1. A top-level array becomes one line per element, with each element written as compact JSON.
  2. A single object that is not in an array becomes a single line, so the tool works for one record as well as many.
  3. Indentation is deliberately removed. A pretty-printed record spans several lines, and in JSONL a newline ends the record, so indentation would corrupt the file.
  4. Nested structure within a record is preserved exactly; only the whitespace between tokens is removed.
  5. The file ends with a trailing newline, which is what streaming readers expect and what stops the last record being missed.

When json to jsonl is useful

Preparing a dataset for import

Most bulk loaders and machine learning pipelines expect one record per line rather than a single array.

Making a large export processable

A multi-gigabyte array cannot be parsed in one go, but a JSONL file of the same records can be read a line at a time.

Check the output

Questions about JSON to JSONL

What is the difference from JSON?

JSONL puts one complete JSON value on each line instead of wrapping everything in one array, which lets a program read records one at a time.

Why is the output not indented?

Because a newline ends a record. Pretty-printing would split one record across several lines and break the format.

Is JSONL the same as NDJSON?

Effectively yes. The names are used interchangeably, and the file extensions .jsonl and .ndjson both appear.

Can records have different fields?

Yes. JSONL imposes no schema, though whatever reads the file might.

Related tools

JSONL to JSON

Turn JSON Lines into a single formatted JSON array in your browser. Names the exact line if one record is malformed.

JSON Formatter and Validator

Format, minify, and validate JSON locally in your browser. Inspect keys, values, nesting depth, and root type without sending private API data to a server.

JSON to CSV Converter

Convert JSON objects to UTF-8 CSV in your browser. Union columns, quote values, and protect formula-like strings.