NDJSON / JSON Lines Converter
Reshape JSON between a single array and one-record-per-line NDJSON — losslessly, with every line validated, entirely on this device.
The trailing newline ends the NDJSON output — array indent applies to the reverse direction.
Press ? for shortcuts
Do it offline:$ jq -c '.[]' file.json
How to use it
- Paste or drop up to 50 MB of either shape; the badge preselects a direction — override it by clicking, pressing s, or picking a tab.
- For an array, choose the indentation — two or four spaces, a tab, or compact; for NDJSON, decide whether a closing newline is written.
- A line that fails to parse is reported by its own number and column with a caret frame, and your paste stays exactly where it sits.
- Copy the result, download it as .ndjson or .json to match the direction, or Share a link that rebuilds the state — nothing is uploaded.
NDJSON — also called JSON Lines or JSONL — writes one JSON value per line instead of one big array, the shape language-model fine-tuning sets and streamed log pipelines expect. This page moves a JSON array to that line-per-record form and back, either direction, on your own device. Long integers keep every digit, and any line that will not parse is named by number before the array is built.
Examples
[{"id":1,"ok":true},{"id":2,"ok":false}]{"id":1,"ok":true}
{"id":2,"ok":false}
Each element becomes its own compact line, so the two objects land as two records; a trailing newline closes the file, as most JSONL readers expect.
{"id":1,"ok":true}
{"id":2,"ok":false}
[
{
"id": 1,
"ok": true
},
{
"id": 2,
"ok": false
}
]The reverse of the first example: the two records rebuild into one array at two-space indent. The final newline reads as end-of-file, never an extra record.
[{"id":1541815603606036481}]{"id":1541815603606036481}
A snowflake id has nineteen digits, beyond a JavaScript number. It survives as a verbatim copy of the source text; through JSON.parse the tail rounds to 1541815603606036500 instead.
["a\nb, c"]"a\nb, c"
The single element is a string holding an escaped newline and a comma. Neither splits the record — the writer keeps the \n escape and the comma inside the quotes — so the value stays on one line.
{"id":1}
{"id":2}
[
{
"id": 1
},
{
"id": 2
}
]Two records split by a blank line, with Windows CRLF endings. The blank line is skipped and the carriage returns normalized, each reported on a note.
Every example on this page is executed against the same engine that powers the tool, on every build.
Gotchas worth knowing
NDJSON, JSON Lines and JSONL are one format
The three names describe one convention: UTF-8 text, one JSON value per line, joined by single newlines. This page reads and writes all three.
Every line is a complete JSON value
A record need not be an object. Any standalone value is legal on a line — a string, a number, true, or a nested array — and each is read or written whole.
Blank lines and the final newline are tolerated
Reading, empty lines are skipped and counted, a final newline is not an extra record, and CRLF folds to LF. Writing, no blank lines return and the closing newline is optional.
Big integers keep every digit
Records move as verbatim slices of your text, never parsed to a floating-point number and back — the step where an id past 2^53, a database bigint or a snowflake, would shed its final digits.
A single JSON array is split element-by-element
Paste one array such as [1,2,3] and detection reads it as array-to-NDJSON: the three elements become three lines, not one record wrapping the array. The reverse needs two or more value lines.
Common errors
This direction needs a top-level JSON array; got an object.- The array-to-NDJSON direction was handed an object, not an array. Switch direction, or wrap the value in brackets first — the badge offers the other reading when a paste looks like records.
line 2: Unexpected end of input at line 1, column 8 — probable cause: the document is incomplete or truncated.- The second record stops before its closing brace, so the whole conversion is refused rather than dropping a line. The leading number points at the record to fix; the inner position counts within that line.
Unexpected '}' at line 1, column 9 — probable cause: trailing comma after the last property.- Going to NDJSON parses the whole array first, so a trailing comma inside one element fails the parse with the shared JSON message — exact line, column and caret frame — before any record is written.
Input is larger than the 50 MB limit for this tool. For bigger payloads use the CLI: jq -c '.[]' file.json (array to JSONL) or jq -s . file.ndjson (JSONL to array).- A refusal, not a partial run: reshaping part of a stream would produce a document that no longer matches the source. The named jq commands do the same job on any size, one per direction.
FAQ
What is NDJSON / JSON Lines and why use it?
It puts one complete JSON value on each line, separated by newlines. Because a reader takes one record at a time without loading the whole file, it suits append-only logs, streamed responses, and the fine-tune sets shipped as .jsonl.
Does converting change my numbers or key order?
No. Each record crosses as an exact slice of your text, so keys keep their order and every digit of a large integer stays put. The reshape only adds or removes the newlines and brackets that tell the layouts apart.
How are blank lines and the trailing newline handled?
Reading NDJSON, empty and whitespace-only lines are skipped and tallied on a note, and a final newline marks end-of-file, not a record. Writing, that closing newline is on by default and optional, and no blank lines appear.
Why did one bad line stop the whole file?
Building the array is fail-closed: if any line will not parse, none is written, since a half-built array would mislead. Up to twenty broken lines are listed by number, with a note when more went unshown, so you fix them in one pass.
Keyboard shortcuts
- ⌘/Ctrl + Enter
- Run the conversion now (large pastes wait for it).
- ⌘/Ctrl + S
- Download the output as .ndjson or .json, by direction.
- ⌘/Ctrl + C
- Copy the whole output when nothing is selected.
- ⌘/Ctrl + Shift + C
- Copy the output even while a selection is active.
- s
- Swap the direction and the two panes (obeys the kill switch).
- t
- Switch the color theme (outside text fields).
- ? or ⌘/Ctrl + /
- Open the shortcut help overlay.
- Esc
- Dismiss the topmost overlay; the input is untouched.