NDJSON Converter

Convert NDJSON (Newline Delimited JSON / JSONL) to a JSON array, or a JSON array back to NDJSON. Free, private, runs entirely in your browser.

What is NDJSON?

NDJSON (Newline Delimited JSON), also called JSONL (JSON Lines), is a text format where each line is a complete, valid JSON object. Unlike a regular JSON array, there is no wrapping [ ] and no commas between records — just one JSON object per line.

NDJSON example:

{"id": 1, "name": "Alice", "role": "admin"}
{"id": 2, "name": "Bob", "role": "user"}
{"id": 3, "name": "Carol", "role": "user"}

Equivalent JSON array:

[
  {"id": 1, "name": "Alice", "role": "admin"},
  {"id": 2, "name": "Bob", "role": "user"},
  {"id": 3, "name": "Carol", "role": "user"}
]

NDJSON vs JSON — When to Use Each

Use Case Best Format Reason
API responsesJSON arrayStandard, easy to parse
Log filesNDJSONAppend one line at a time
BigQuery / data exportsNDJSONRequired format for bulk load
Elasticsearch bulk APINDJSONRequired by the API spec
ML training datasetsNDJSON / JSONLStream line by line, memory efficient
Config filesJSONEasier to read and edit
OpenAI fine-tuningJSONLRequired format for training files

How to Convert NDJSON to JSON

  1. Click "Open NDJSON Converter" above
  2. Paste your NDJSON data (one JSON object per line)
  3. Select "NDJSON → JSON Array" mode
  4. Click Convert — the output is a standard JSON array
  5. Copy or download the result

To go the other direction (JSON array to NDJSON), select "JSON Array → NDJSON" mode and paste your JSON array.

Frequently Asked Questions

What file extension does NDJSON use?

NDJSON files use the .ndjson or .jsonl extension. Both are identical in format. Google BigQuery documentation uses .ndjson, while the JSON Lines specification uses .jsonl. Most tools accept both extensions.

How do I parse NDJSON in Python?

Read the file line by line and parse each line as JSON:

import json
with open('data.ndjson') as f:
    records = [json.loads(line) for line in f if line.strip()]

How do I parse NDJSON in JavaScript / Node.js?

const records = fs.readFileSync('data.ndjson', 'utf8')
  .split('\n')
  .filter(line => line.trim())
  .map(line => JSON.parse(line));

Why does BigQuery require NDJSON instead of JSON?

BigQuery processes data in parallel across many workers. NDJSON allows each worker to read a chunk of lines independently without needing to parse the entire file structure first. A JSON array requires knowing where the array starts and ends, which prevents efficient parallel processing of large files.

Convert your NDJSON now

Free, instant, 100% private. No account needed.

What is NDJSON (Newline Delimited JSON)?

NDJSON (Newline Delimited JSON), also known as JSONL (JSON Lines), is a plain-text data format where each line contains exactly one complete, self-contained JSON value — typically a JSON object. The file has no wrapping structure: no outer array brackets, no commas between records, and no shared root element. Every line is independently parseable.

This design makes NDJSON the preferred format for streaming, logging, and large dataset processing because:

NDJSON is defined at ndjson.org and uses the file extension .ndjson. The identical JSON Lines specification at jsonlines.org uses the extension .jsonl. The two formats are completely interchangeable.

How to Convert NDJSON to JSON Array

Converting NDJSON to a JSON array is straightforward: read each non-empty line, parse it as a JSON object, and wrap all the objects inside a [ ] array. The resulting JSON array is the standard format accepted by most REST APIs, JavaScript code, and JSON processing tools.

NDJSON Input to JSON Array Output

// NDJSON Input (each line is a separate JSON object)
{"id": 1, "event": "login",   "user": "alice", "ts": "2024-03-15T09:00:00Z"}
{"id": 2, "event": "view",    "user": "alice", "ts": "2024-03-15T09:01:32Z"}
{"id": 3, "event": "purchase","user": "bob",   "ts": "2024-03-15T09:04:11Z"}
{"id": 4, "event": "logout",  "user": "alice", "ts": "2024-03-15T09:07:55Z"}

// JSON Array Output (standard JSON, wraps all objects in [ ])
[
  {"id": 1, "event": "login",    "user": "alice", "ts": "2024-03-15T09:00:00Z"},
  {"id": 2, "event": "view",     "user": "alice", "ts": "2024-03-15T09:01:32Z"},
  {"id": 3, "event": "purchase", "user": "bob",   "ts": "2024-03-15T09:04:11Z"},
  {"id": 4, "event": "logout",   "user": "alice", "ts": "2024-03-15T09:07:55Z"}
]

Convert NDJSON to JSON in Code

// JavaScript / Node.js
const ndjsonToArray = (ndjson) =>
  ndjson.split('\n')
        .filter(line => line.trim())
        .map(line => JSON.parse(line));

// Python
import json
def ndjson_to_array(text):
    return [json.loads(line) for line in text.splitlines() if line.strip()]

// Bash (using jq)
jq -s '.' input.ndjson > output.json

// Command line (Node.js one-liner)
node -e "const d=require('fs').readFileSync('data.ndjson','utf8');
console.log(JSON.stringify(d.split('\n').filter(l=>l.trim()).map(JSON.parse),null,2));"

Convert JSON Array Back to NDJSON

// JavaScript
const arrayToNdjson = (arr) => arr.map(obj => JSON.stringify(obj)).join('\n');

// Python
def array_to_ndjson(arr):
    return '\n'.join(json.dumps(obj) for obj in arr)

// Bash (using jq)
jq -c '.[]' input.json > output.ndjson

NDJSON vs JSON: Key Differences

Choosing between NDJSON and a JSON array depends on how you plan to read, write, and process the data. Here is a detailed comparison of both formats:

Feature NDJSON / JSONL JSON Array
StructureOne JSON object per line, no wrapperAll objects inside [ ] with commas
File sizeSlightly smaller (no commas between records)Slightly larger due to commas and brackets
StreamingProcess one line at a time; O(1) memory per recordMust parse entire document before reading any record
Appending recordsTrivial: append a new line to the fileMust parse and rewrite to insert the closing ]
Partial failure recoveryOnly the incomplete line is lostA missing ] renders the entire file unparseable
ReadabilityEach record is compact; easy to scan with grep/headPretty-printed JSON is easier to read in a text editor
API compatibilityRequired by BigQuery, Elasticsearch, OpenAI fine-tuningStandard format for REST API responses
Parallel processingSplit by lines; workers process independent chunksRequires index-based splitting after parsing
File extensions.ndjson or .jsonl.json

Also useful: JSON Formatter | JSON to CSV | JSON to XML | JSON Diff | JSON Validator