What does this converter do?
This converter turns a JSON value into newline-delimited JSON.
Most often, that means turning a JSON array like this:
[
{ "level": "info", "message": "Started" },
{ "level": "warn", "message": "Slow response" },
{ "level": "error", "message": "Something failed" }
]
into NDJSON like this:
{"level":"info","message":"Started"}
{"level":"warn","message":"Slow response"}
{"level":"error","message":"Something failed"}
Each item in the original array becomes one compact JSON line.
When is JSON to NDJSON useful?
Regular JSON arrays are useful for APIs, configuration, fixtures, and documents that are meant to be loaded as a complete value.
NDJSON is useful when records need to be handled one at a time.
That makes NDJSON helpful for:
- logs
- exports
- command-line tools
- streaming data
- large record sets
- search indexing
- queue-style processing
- data pipelines
In practical terms, JSON arrays are often good for passing data around as one object. NDJSON is often good for processing records line by line.
How this converter works
This converter keeps the process intentionally simple:
- It reads your JSON input.
- It parses the input as JSON.
- If the top-level value is an array, each array item becomes one NDJSON line.
- If the top-level value is not an array, the value is converted into one NDJSON line.
- It reports the input type, output line count, and any parse error.
The output is compact by design. NDJSON expects one JSON value per line, so each record is written on a single line. After if you would like to improve the formatting, you can check out my ndjson formatter or if you're working with a lot of NDJSON files, the Siteimp log workbench is a great choice with the same privacy protections as built into this site and it uses localStorage so you can keep multiple files open and compare them.
Privacy and local files
This page runs in your browser. There is no account, no backend upload, and no server-side storage.
If you open a local file, your browser reads the file so this page can convert it. The file is not uploaded to hluska.ca.
If you refresh or close the page, the current input and output are gone. That is intentional.
Want to test that?
After this page loads, turn off your internet connection and try using the converter. It will still work because this tool was designed to be local first.
You can also open your browser developer tools, check the Network tab, and then convert a file. Again, if the file gets uploaded anywhere, I have made a really big mistake... please contact me.
That does not mean every browser tool is safe. It just gives you a practical way to check what this page is doing.
Before sharing converted data
Converting JSON to NDJSON changes the shape of the data. It does not automatically make the data safe to share.
Before sending converted data to another person or company, check for values such as:
- tokens
- secrets
- passwords
- email addresses
- usernames
- file paths
- machine names
- internal URLs
- customer data
- session IDs
- API keys
Unless you have strong protections in place, including legal and data sharing documents where appropriate, you will usually be better off copying only the records you need. Or remember, the web is not the only way to run software and you can often find tools you can install on your own infrastructure so you can control whatever machine your data touches.