
Security News
CVE Volume Surges Past 48,000 in 2025 as WordPress Plugin Ecosystem Drives Growth
CVE disclosures hit a record 48,185 in 2025, driven largely by vulnerabilities in third-party WordPress plugins.
Transform a stream of JSON into a stream of Line Delimited JSON
$ npm install --save jsonl
var fs = require("fs")
var jsonl = require("jsonl")
fs.createReadStream("./in.json")
.pipe(jsonl())
.pipe(fs.createWriteStream("./out.json"))
in.json[{"test":"value"},{"test":"value"},{"test":"value"},{"test":"value"}]
out.json{"test":"value"}
{"test":"value"}
{"test":"value"}
{"test":"value"}
var fs = require("fs")
var jsonl = require("jsonl")
var through = require("through2")
var stream = through.obj()
stream.pipe(jsonl({toBufferStream:true}))
.pipe(fs.createWriteStream("./out.json"))
stream.push({test:"value"})
stream.push({test:"value"})
stream.push({test:"value"})
stream.push({test:"value"})
stream.end()
out.json{"test":"value"}
{"test":"value"}
{"test":"value"}
{"test":"value"}
To get the results you expect, you will likely need to know the structure of your incoming data. You may have to pass a depth property, which corresponds to the layer of the property in a serialized, nested JSON object.
By default, jsonl will use a depth of 1 when reading data from a Buffer stream (expecting objects to be nested in an array), and a depth of 0 from a stream in object mode.
/*0*/[
/*1*/ {
/*2*/ test: "value"
/*1*/ },
/*1*/ {
/*2*/ test: "value"
/*1*/ }
/*0*/]
To filter the incoming data based on properties, you can select specific fields to be plucked out of the incoming object.
* You will need to specify a depth property for the nested level of the property.
var fs = require("fs")
var jsonl = require("jsonl")
fs.createReadStream("./in.json")
.pipe(jsonl({pluck:["category"], depth:2}))
.pipe(fs.createWriteStream("./out.json"))
in.json[{"category": "cactus heights", "question":"?", "answer": "!"},{"category": "giraffe shoe sizes", "question":"?", "answer": "!"}]
out.json{"category":"cactus heights"}
{"category":"giraffe shoe sizes"}
Number (default: 1)The depth of the objects in the incoming data to pluck out. This is what you want for an array of objects, such as:
[{"this":"that"},{"this":"that"}]
Boolean (default: false)Convert data into an object stream.
Array|String (default: [])Only return select properties from JSON objects.
String (default: \n)String to separate object data with.
Boolean (default: false)Set this to true when you have an object stream that you would like converted to a stream of line delimited JSON buffers.
If set, this defaults opts.depth to 0, but can still be overridden.
MIT © Stephen Sawchuk
FAQs
Transform a stream of JSON into a stream of Line Delimited JSON
We found that jsonl demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
CVE disclosures hit a record 48,185 in 2025, driven largely by vulnerabilities in third-party WordPress plugins.

Security News
Socket CEO Feross Aboukhadijeh joins Insecure Agents to discuss CVE remediation and why supply chain attacks require a different security approach.

Security News
Tailwind Labs laid off 75% of its engineering team after revenue dropped 80%, as LLMs redirect traffic away from documentation where developers discover paid products.