00

The short answer

  • JSON Lines is a text data format that stores structured records one JSON value per line, requiring UTF-8 without a BOM and no blank lines.
  • On Windows or macOS, open the file in a text editor with UTF-8 support. On a phone, use a text editor that can select the file and read UTF-8; file access and size limits depend on that app. For processing, parse each line separately with a JSON parser. Unix text tools and shell pipelines can work with the line structure. LF and CRLF line endings are supported. JSON Lines recommends a final newline, while NDJSON requires one after every JSON text.
  • The format has low inherent risk: compliant JSON syntax excludes assignments and function calls. Use a JSON parser for untrusted text; eval or similar functions can introduce code execution risks. Successful parsing does not establish that the content is trustworthy or that a conversion preserved all values.
01

JSON Lines (.jsonl, .ndjson): opening and converting files

JSON Lines, also called newline-delimited JSON, suits records, logs and messages processed individually. Each line can contain an object, array or scalar; null is valid. JSON Lines uses .jsonl, while the NDJSON specification recommends .ndjson. The JSON Lines documentation proposes application/jsonl but says it is not standardized; NDJSON recommends application/x-ndjson.

Keep the original

To convert JSONL to a conventional JSON document, collect the line values in order into one array. This follows from the formats' structures; renaming the extension does not perform the conversion. Inspect duplicate object keys and number precision before parsing and exporting. A CSV conversion also needs an explicit mapping for arrays, nested values and differing record shapes.

02

How to open it

On Windows or macOS, open the file in a text editor with UTF-8 support. On a phone, use a text editor that can select the file and read UTF-8; file access and size limits depend on that app. For processing, parse each line separately with a JSON parser. Unix text tools and shell pipelines can work with the line structure. LF and CRLF line endings are supported. JSON Lines recommends a final newline, while NDJSON requires one after every JSON text.

I only want to read it

On Windows or macOS, open the file in a text editor with UTF-8 support. On a phone, use a text editor that can select the file and read UTF-8; file access and size limits depend on that app. For processing, parse each line separately with a JSON parser. Unix text tools and shell pipelines can work with the line structure. LF and CRLF line endings are supported. JSON Lines recommends a final newline, while NDJSON requires one after every JSON text.

I need to send it to someone

To convert JSONL to a conventional JSON document, collect the line values in order into one array. This follows from the formats' structures; renaming the extension does not perform the conversion. Inspect duplicate object keys and number precision before parsing and exporting. A CSV conversion also needs an explicit mapping for arrays, nested values and differing record shapes.

03

File safety

The format has low inherent risk: compliant JSON syntax excludes assignments and function calls. Use a JSON parser for untrusted text; eval or similar functions can introduce code execution risks. Successful parsing does not establish that the content is trustworthy or that a conversion preserved all values.

Stop if any of this looks off

An unknown sender, a name ending in two extensions, or contents that do not match the extension — check before you open it.

04

Converting it

To convert JSONL to a conventional JSON document, collect the line values in order into one array. This follows from the formats' structures; renaming the extension does not perform the conversion. Inspect duplicate object keys and number precision before parsing and exporting. A CSV conversion also needs an explicit mapping for arrays, nested values and differing record shapes.

Before you convert

Convert a copy, never the original, then compare quality, metadata, and layout against what you started with.

05

Common questions

What is a JSON Lines file used for?

JSON Lines stores one JSON value per line for individually processed records, logs and messages. A line can hold an object, array or scalar, including null. Blank lines are not valid JSON Lines records.

How do I open JSONL files on Windows?

Open a .jsonl file from a text editor that supports UTF-8. Read each line as a separate JSON value. For structured processing, use a parser that reads JSON line by line; a parser expecting one JSON document may reject multiple records.

How do I open JSONL files on Mac?

Use a text editor in plain-text mode with UTF-8 encoding. Each record should occupy one line. For command-line processing, the line structure works with Unix text tools and shell pipelines, followed by JSON parsing for each line.

How do I open NDJSON files on a phone?

Choose a text editor that can access the file on your phone and display UTF-8 text, then open the .ndjson file in it. Supported file sizes and file access depend on the app; the format does not guarantee mobile app compatibility.

Why do NDJSON parsing errors occur around blank lines?

JSON Lines does not allow blank lines. NDJSON parsers may ignore them if that behavior is documented and should make the option configurable, so tools can differ. Inspect the failing line and check for empty lines, incomplete JSON or a record split across lines.

Should I use JSON Lines or ordinary JSON for multiple records?

Use JSON Lines when records should be read or processed individually by line. Use an ordinary JSON array when the recipient expects one JSON document. Multiple JSON values separated by newlines do not form a single valid JSON document.

How do I convert JSONL to a JSON array?

Parse each line as a JSON value, preserve the record order and write the values inside one array with commas between them. This conversion follows from the formats' structures. Changing .jsonl to .json alone does not convert the records.

What data loss should I check for when converting JSONL to CSV?

Define how nested objects, arrays and records with different fields map to CSV columns. Also check duplicate object keys and large or high-precision numbers: parsing may retain only the last duplicate value or alter numbers beyond the tool's precision.

What are the safety risks of parsing a JSONL file?

Compliant JSON syntax excludes assignments and function calls, but using eval or similar functions on untrusted text can introduce code execution risks. Use a JSON parser. A file that parses successfully is not proof that its contents are trustworthy.

How do I fix JSON Lines UTF-8 encoding errors?

Confirm the original text encoding, then save a correctly decoded copy as UTF-8 without a BOM. JSON Lines requires that encoding. If characters were already replaced during decoding, changing the encoding label will not reconstruct the original text.

What file size and nesting limits apply to JSONL files?

The JSON Lines, NDJSON and JSON specifications do not set a universal size limit for opening a file. Parsers may limit text size, nesting depth and string length. Unpaired Unicode surrogates can also cause unpredictable behavior or runtime errors, so check the limits of the reader you use.

06

Related formats

Sources

JSON Lines — 官方格式文档 · JSON Lines 格式项目,维护者 Ian Ward

NDJSON — Newline delimited JSON Specification · NDJSON 官方规范仓库

RFC 8259 — The JavaScript Object Notation (JSON) Data Interchange Format · IETF Standards Track / RFC Editor