Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Streaming JSON.stringify()
branch: master
Failed to load latest commit information.
test allow passing space and replacer in options
.gitignore update package
.travis.yml support 0.8
LICENSE update package update package
index.js allow passing space and replacer in options
package.json 2.1.0

Streaming JSON.stringify()

NPM version Build status Test coverage Dependency Status License Downloads Gittip

Similar to JSONStream.stringify() except it is, by default, a binary stream, and it is a streams2 implementation.


The main use case for this is to stream a database query to a web client. This is meant to be used only with arrays, not objects.

var Stringify = require('streaming-json-stringify')

app.get('/things', function (req, res, next) {
  res.setHeader('Content-Type', 'application/json; charset=utf-8')


will yield something like



  • The stream always starts with '[\n'.
  • Documents are separated by '\n,\n'.
  • The stream is terminated with '\n]\n'.



Returns a Transform stream. The options are passed to the Transform constructor.

JSON.stringify options

You can override these:

var stringify = Stringify()
stringify.replacer = function () {} = 2
Something went wrong with that request. Please try again.