Loading NDJSON Minifier...
Please wait a moment

How to Minify NDJSON Data

Remove unnecessary whitespace from your Newline Delimited JSON to reduce file size and bandwidth

Step 1

Input Your NDJSON Data

Paste your NDJSON data that may contain extra whitespace, indentation, or pretty-printed formatting. Each line will be compacted to its smallest valid form while preserving all JSON data.

Paste directly: Copy NDJSON with extra whitespace from editors or formatted data exports
Upload a file: Click "Upload" to select a .ndjson, .jsonl, or .txt file
Try the sample: Click "Sample" to see minification with spaced-out JSON lines

Example: Formatted NDJSON Input

Pretty-printed NDJSON lines with extra whitespace — common from development environments or formatted exports:

{ "id": 1, "name": "Widget A", "price": 9.99, "in_stock": true, "category": "tools" }
{ "id": 2, "name": "Widget B", "price": 24.99, "in_stock": false, "category": "tools" }
{ "id": 3, "name": "Widget C", "price": 4.49, "in_stock": true, "category": "hardware" }

Approx. 330 bytes with whitespace — the minifier will reduce this significantly.

Step 2

Automatic Minification

The minifier processes each JSON Lines entry and produces the most compact valid form by parsing and re-serializing each line:

Whitespace removal: Strips all spaces, tabs, and indentation between JSON tokens
Size savings display: Shows exactly how many bytes were saved and the percentage reduction
Data integrity check: Each line is parsed and re-serialized to guarantee valid, semantically identical output
Error skipping: Invalid lines are flagged and skipped — only valid JSON lines appear in the output

Example: Minified NDJSON Output

All unnecessary whitespace removed — same data, minimum bytes, ready for production APIs and Kafka streams:

{"id":1,"name":"Widget A","price":9.99,"in_stock":true,"category":"tools"}
{"id":2,"name":"Widget B","price":24.99,"in_stock":false,"category":"tools"}
{"id":3,"name":"Widget C","price":4.49,"in_stock":true,"category":"hardware"}

Approx. 240 bytes after minification — roughly 27% smaller than the formatted version.

Step 3

Export Minified NDJSON

Get the compact NDJSON ready for production use and deployment:

Copy to clipboard: Paste minified NDJSON directly into your application, API request, or script
Download as .ndjson: Save the minified file for faster network transfers and storage
Reduced size: Smaller files mean faster uploads, lower bandwidth costs, and less storage needed

Why Minify NDJSON?

Minifying NDJSON removes all non-essential whitespace from each JSON Lines record while keeping the data semantically identical. When sending data to production systems like the Elasticsearch Bulk API or streaming to Apache Kafka, smaller payloads mean lower latency and reduced costs.

Heavily formatted NDJSON with indentation and extra spaces can be 30–60% larger than its minified equivalent. For log shipping pipelines, large-scale data ingestion, or API bulk operations, this overhead adds up quickly. Minification combined with HTTP compression (gzip/brotli) gives the best transfer performance.

The minifier parses and re-serializes each line using the browser's native JSON engine, which guarantees output validity. This is safer than regex-based whitespace removal, which can corrupt data if whitespace appears inside string values. Use our NDJSON Validator first if your data may contain syntax errors before minifying.

Frequently Asked Questions

What does NDJSON minification do?

Minification removes unnecessary whitespace (spaces, tabs, and indentation) from each JSON line while preserving all data. Each line is parsed and re-serialized using the browser's native JSON engine in the most compact form possible, following the NDJSON specification.

Does minification change my data?

No. Only whitespace outside of string values is removed. All keys, values, data types, and structure remain identical. The minified output is semantically equivalent to the original — any system that accepts the original will accept the minified version.

How much space can I save?

Savings depend on how much whitespace your original data contains. Heavily formatted JSON with indentation can see 30–60% size reduction. Already compact NDJSON may see minimal savings. The tool displays the exact byte savings and percentage after minification.

When should I minify NDJSON?

Minify before sending to production APIs like the Elasticsearch Bulk API, when writing to log shipping systems, or before storing in object storage. Use formatted (unminified) NDJSON during development for readability, then minify for production deployments.

What tools commonly use NDJSON?

The Elasticsearch Bulk API, Apache Kafka producers and consumers, Google BigQuery JSON imports, MongoDB mongoexport, AWS Kinesis, and structured logging libraries like Pino, Bunyan, and Winston all use the NDJSON / JSON Lines format.

Should I validate before minifying?

If your data may contain malformed lines, it is a good practice to run our NDJSON Validator first. The minifier will skip invalid lines automatically, but knowing which lines failed helps you fix data quality issues at the source before deploying.

Is this minifier free?

Yes, completely free with no limits. All processing happens in your browser — your data never leaves your device.