NDJSON <-> JSON Array
Turn NDJSON / JSON Lines (one JSON value per line) into a single JSON array, or split a JSON array into one compact JSON value per line. Blank lines are ignored; a malformed line is reported by number.
🔒 100% Client-Side & Private — processed locally in your browser. Files never leave your device.
Options
Your result will appear here
Type or paste your input above, adjust the options, then press Run. Tip: press Ctrl+Enter to run, and ? for every shortcut.
How it works
Two directions behind one switch
In the default direction every non-blank input line is parsed as a JSON value and collected into a single JSON array, with a malformed line reported by its line number. Switch Direction to "JSON array → NDJSON" and a top-level array is emitted as one compact JSON value per line. Either way the stats report how many elements came out.
Where NDJSON turns up
Use it when a log pipeline, a bulk upload endpoint, a warehouse export or a streaming API wants JSON Lines but you hold an array, or when someone hands you NDJSON and you need to read it as one document. It is also the fastest way to pretty-print a file of one-record-per-line data.
The indent switch only works one way
In the NDJSON → array direction, Array output chooses between compact output and two-space pretty printing, which is what you want when reading or diffing the result. The other direction emits one compact value per line by definition, because pretty-printing would break the format, so the option is hidden and ignored there.
What gets rejected
Blank and whitespace-only lines are skipped, but every other line must be a complete JSON value: trailing commas, comments and bare unquoted strings are not JSON and raise an error naming the offending line. Producing NDJSON requires a top-level array, so a single object is refused, and a null element is written as the JSON token null.
Converted inside the tab
All parsing and serialising happens in your browser and the records are never uploaded. You can convert internal exports or customer data freely, with no network connection.
Questions
What counts as a line?
Input is split on newlines. Empty or whitespace-only lines are skipped; every other line must be a complete JSON value.
Does the indent option affect NDJSON output?
No. When producing NDJSON each line is always a single compact JSON value. The indent option only pretty-prints the array in the other direction.
What about a byte-order mark or trailing whitespace?
A blank or whitespace-only line is skipped, and trailing spaces on a line are harmless because JSON.parse ignores surrounding whitespace. A byte-order mark at the very start is not: JSON.parse rejects it, so strip the BOM before converting.
Related tools
See categoryJSON Formatter & Validator
Pretty-print, minify, recursively sort keys or validate JSON, with line/column errors.
Flatten JSON
Flatten nested JSON to dotted keys (users.0.name) or collapse dotted keys back into nested JSON.
.env <-> JSON
Parse a .env file into JSON, or turn a JSON object into .env text. Runs entirely on your device.
ASCII Table Generator
Turn CSV (or tab-separated) rows into a bordered ASCII table for docs, emails and code comments.