Skip to content

JSON vs JSON Lines: what is the difference?

What changes when JSON is written one record per line, where each format is used, and how to open and convert a .jsonl file.

By OpenAnyDoc ·

The short answer

A JSON file holds one value, usually one object or one list, and a program has to read the whole file before it can use it. A JSON Lines file (.jsonl, also written NDJSON, .ndjson) holds one JSON value on each line, so records can be read, written or appended one at a time. OpenAnyDoc's JSON viewer opens both kinds in your browser without uploading the file, and shows a .jsonl or .ndjson file as a list with one item per line.

The same three records, written both ways

Here are three synthetic log events. As one JSON document they sit inside square brackets, with a comma between them:

  • JSON: [{"id":1,"event":"login"},{"id":2,"event":"upload"},{"id":3,"event":"logout"}]
  • JSON Lines, line 1: {"id":1,"event":"login"}
  • JSON Lines, line 2: {"id":2,"event":"upload"}
  • JSON Lines, line 3: {"id":3,"event":"logout"}

What the JSON Lines rules say (checked 24 November 2026)

jsonlines.org sets three rules and two conventions. The NDJSON specification describes the same layout under another name.

  • The text is UTF-8, without a byte order mark.
  • Each line is one valid JSON value. null is a valid line; a blank line is not.
  • Lines end with a newline (\n). Windows line endings (\r\n) also work, because spaces around a JSON value are ignored.
  • A newline after the last line is strongly recommended but not required.
  • Files may use the .jsonl extension, and the media type may be application/jsonl, which is not yet standardized.
  • The NDJSON specification asks for the .ndjson extension and the media type application/x-ndjson.

When each one is used

In JSON Lines there are no brackets around the file and no commas between records, and each line is complete on its own. A program can add a record by writing one more line at the end, without reading the file first, and the file can be split at any line break with every part still valid.

So a rough rule: JSON when the data is read as one piece, JSON Lines when it is a stream of separate records.

  • JSON: API responses, configuration files and small exports that a program loads in one go.
  • JSON Lines for logs: jsonlines.org calls it a great format for log files, because each event is one line that can be appended.
  • JSON Lines between programs and in shell pipelines, where tools read and write one line at a time.
  • JSON Lines for AI batch and training files. OpenAI's Batch API guide says batches start with a .jsonl file in which each line holds one request, and its fine-tuning guide asks for training data in JSONL format, one complete JSON structure per line (both checked 24 November 2026).

How to open a .jsonl or .ndjson file

Drop the file on the JSON viewer, or choose it. It is read on your device; nothing is sent to a server.

  • Each line becomes one item of a list, and a note says "Opened from JSON Lines: each line is an item of the list. Download saves JSON Lines again."
  • The tree, table and text views work as they do for any JSON file. A file of records with the same fields reads best in the table.
  • Blank lines are skipped rather than refused, so a file with an empty line at the end still opens.
  • If one line is not valid JSON, the viewer stops and gives the number of that line, so you know where to look.
  • Download saves the file as JSON Lines again, one item per line, with your edits.
  • Files up to 10 MB open. The extension decides how the file is read: a JSON Lines file saved with a .json name is read as ordinary JSON and fails, so rename it to .jsonl first.

How to convert between them

Once the .jsonl file is open in the JSON viewer:

  • To JSON: open the Copy menu and choose Copy formatted. You get the records as one JSON list, inside square brackets, ready to paste or save.
  • To a spreadsheet: open the Convert menu and choose Convert to CSV or Convert to Excel (.xlsx). Each record becomes a row and each field a column.
  • From a JSON list to JSON Lines: OpenAnyDoc has no button for this direction yet. A command-line tool such as jq writes one item per line with jq -c ".[]".

Why does my .jsonl file give an "Unexpected non-whitespace character" error?

That error means a program read the file as one JSON document and found a second value after the first line. The file is probably fine as JSON Lines. Open it with a tool that reads JSON Lines, or check that it is saved with a .jsonl or .ndjson name. The guide to unexpected token errors explains the other messages.

Is NDJSON the same as JSON Lines?

For everyday use, yes: both put one JSON value on each line and end lines with a newline. They come from two separate write-ups, so the names differ, and so do the suggested extension and media type: .jsonl for JSON Lines, .ndjson and application/x-ndjson for NDJSON. OpenAnyDoc's JSON viewer opens both extensions the same way.

Can I open a JSON Lines file in Excel?

Not directly as a table, because Excel has no reader for one-object-per-line files. Open the .jsonl file in OpenAnyDoc's JSON viewer, choose Convert to Excel (.xlsx) from the Convert menu, and download the workbook. Nested fields become their own columns. How to open a JSON file covers the other ways to read JSON.

Is my file uploaded when I open it here?

No. The JSON viewer reads JSON and JSON Lines files with your own browser, on your device, and keeps them in the page's memory until you close the tab. Nothing is sent to a server, which matters for logs and AI batch files that often hold user data. You can check this yourself in the browser's network panel.

Questions?

Write to support@openanydoc.com and describe the file and what you see when you open it (no personal data).