Skip to content
← All Tools
๐Ÿ”’All processing in your browser ๐ŸšซNo uploads stored ๐Ÿ›ก๏ธPrivacy-first conversion tools โœ“No login required
Tutorial

How to Use the Json To Ndjson: Step-by-Step Tutorial

Bill Crawford — Developer Tutorial — 2026  ยท  Published April 14, 2026

The JSON to NDJSON Converter runs entirely in your browser โ€” your JSON file is never sent to any server, no account is required, and nothing leaves your machine. This tutorial walks through every step of using the tool: choosing an input mode, loading or pasting JSON, running the conversion, reading the stats panel, previewing the output, and downloading the result. It also covers the edge cases you are most likely to encounter and explains how the tool handles each one.

Connect on LinkedIn โ†’

Follow along with the tool open: Open the JSON to NDJSON Converter in a second tab, then work through each step below.

Open JSON to NDJSON Converter โ†’

Table of Contents

  1. Step 1 โ€” Open the Tool
  2. Step 2 โ€” Choose an Input Mode
  3. Step 3a โ€” Upload a JSON File
  4. Step 3b โ€” Paste JSON Directly
  5. Step 4 โ€” Run the Conversion
  6. Step 5 โ€” Read the Stats Panel
  7. Step 6 โ€” Preview the Output
  8. Step 7 โ€” Download the Result
  9. Edge Cases and How the Tool Handles Them
  10. Worked Example

Step 1 โ€” Open the Tool

Navigate to /developer-tools/json-to-ndjson/. The tool loads entirely in the browser โ€” after the initial page load, converting a file makes zero outbound network requests. You can confirm this in your browser's DevTools Network panel: drop a file and watch the network tab remain idle while the conversion runs.

The tool is accessible from the Developer Tools hub, the command palette (press Ctrl+K or โŒ˜K and type "JSON to NDJSON"), or directly via the URL above.

Step 2 โ€” Choose an Input Mode

The tool box has two tabs at the top: File and Paste. Click whichever tab matches how you want to provide your JSON.

If you are unsure which to use, start with File mode. If you want to quickly convert a small snippet without saving it to disk first, use Paste mode.

Step 3a โ€” Upload a JSON File

In File mode, load your JSON in one of two ways:

To clear the loaded file and load a different one, click the โœ• button in the filename bar. The tool resets to its initial state, ready for a new file.

Step 3b โ€” Paste JSON Directly

In Paste mode, click inside the text area and type or paste your JSON. The text area accepts any JSON: compact single-line, pretty-printed multi-line, or anything in between. Whitespace in the input does not affect the output โ€” the converter calls JSON.parse() on the entire input text, then re-serializes each element with JSON.stringify(), so the output is always compact regardless of the input formatting.

To clear the text area and start over, click the Clear button beneath it.

Step 4 โ€” Run the Conversion

Once your input is loaded or pasted, click the Convert to NDJSON button. The conversion runs in JavaScript in your browser tab. For most files under a few megabytes, results appear within a second. For very large files โ€” 50 MB or more โ€” the conversion may take a few seconds; the button disables during processing to prevent double-clicks.

The conversion validates the input first by calling JSON.parse(). If the input is not valid JSON, an error message appears describing the syntax problem โ€” no output is produced until the input parses correctly. Fix the error in your file or paste, then click Convert again. Clicking Convert also clears any output from a previous run, so you can convert multiple files in sequence without reloading the page.

Step 5 โ€” Read the Stats Panel

After a successful conversion, a stats panel appears below the button. It reports:

If any warnings are present โ€” input is a single object, input is an empty array, input is a primitive โ€” they appear in this panel. Warnings do not prevent the output from being downloaded, but they signal that the input may not be what was intended.

Step 6 โ€” Preview the Output

Below the stats panel, a preview panel shows the first five lines of the NDJSON output. Each line is the compact JSON serialization of one array element, with all whitespace removed. Scan the preview to confirm:

The preview is truncated to 5 lines for readability. To inspect more records, download the output file and open it in a text editor. For large files, a command-line tool like head -20 output.ndjson will show the first 20 records.

Step 7 โ€” Download the Result

Click the Download .ndjson button to save the output file. The file is named by replacing the .json extension of the input file with .ndjson. For pasted input, the file is named pasted-input.ndjson. The download goes to your browser's default download folder.

After downloading, verify the file in your destination system before using it in production. For Elasticsearch, run a test _bulk request with the first few lines. For BigQuery, run a dry-run load job. For Spark or DuckDB, read the first 100 records and confirm the schema looks correct. The stats panel's record count should match the row count you see in the destination system.

Edge Cases and How the Tool Handles Them

Single JSON object as input. If your JSON is a single object rather than an array โ€” for example, {"data": [...], "meta": {...}} โ€” the converter writes a single-line NDJSON file containing that one object and shows a warning. This is usually not the intended behavior. Inspect the JSON to find the inner array (likely the data key in the example above) and extract it before converting. In JavaScript: JSON.stringify(input.data) produces the inner array as a string that you can paste into Paste mode.

Empty array. If the input is [], the converter produces an empty NDJSON file (zero lines) and warns that the output contains no lines. This is valid but almost always indicates the wrong file was loaded โ€” check that you are loading the expected export and not an empty placeholder.

JSON parse error. If the input fails to parse, the error panel shows the parser's error message and the approximate position of the problem. Common causes are: trailing commas ({a: 1,}), single-quoted strings ('text'), JavaScript comments (// comment), and unescaped newlines inside string values. Fix the issue in the source file and reload, or edit the pasted text and click Convert again.

Large files. Files above 50 MB are processed in File mode. Paste mode works for large inputs but may be slower due to text area rendering overhead. For very large files (over 100 MB), browser memory limits may cause the tab to slow or crash โ€” in that case, split the file into chunks using a command-line tool before converting.

Unicode and special characters. The converter reads the input as UTF-8 and writes the output as UTF-8. Multi-byte characters โ€” emoji, CJK ideographs, accented characters โ€” pass through unchanged. Strings containing characters that must be escaped in JSON (\n, \t, \\, \") are escaped automatically by JSON.stringify().

Nested objects. If records contain nested objects or arrays, they appear as inline JSON in each NDJSON line. For example, a record {"id": 1, "address": {"city": "Austin", "state": "TX"}} becomes a single NDJSON line: {"id":1,"address":{"city":"Austin","state":"TX"}}. Most NDJSON consumers (Elasticsearch, Spark, DuckDB) handle nested objects natively. If the target system requires a flat schema, flatten the records before converting.

Worked Example

This section shows a complete conversion from start to finish using a small JSON array.

Input JSON (paste this into Paste mode):

[
  {"id": 1, "name": "Alice", "role": "admin", "active": true},
  {"id": 2, "name": "Bob", "role": "editor", "active": true},
  {"id": 3, "name": "Carol", "role": "viewer", "active": false}
]

Steps to follow:

  1. Open the JSON to NDJSON Converter.
  2. Click the Paste tab.
  3. Paste the JSON above into the text area.
  4. Click Convert to NDJSON.
  5. The stats panel shows: Records: 3, output size approximately 120 bytes, input type: array.
  6. The preview panel shows three lines โ€” one per record.
  7. Click Download .ndjson. The file is saved as pasted-input.ndjson.

Expected NDJSON output:

{"id":1,"name":"Alice","role":"admin","active":true}
{"id":2,"name":"Bob","role":"editor","active":true}
{"id":3,"name":"Carol","role":"viewer","active":false}

Each record is on its own line, whitespace is removed, and the file ends without a trailing blank line. This file can be loaded directly into Elasticsearch via the Bulk API (with action lines added), ingested by Spark with spark.read.json("pasted-input.ndjson"), or processed with jq as a stream.

For a deeper explanation of what NDJSON is, when to use it, and how the conversion works under the hood, see the Complete Guide to Json To Ndjson.

BC
Bill Crawford
Founder, Data Conversion Center

Bill Crawford is a data systems developer and technical founder with over 30 years of professional experience in accounting, finance, and business operations. He founded DataConversionCenter.com to build practical, browser-based tools that simplify complex data challenges.

Professional Background