JSON payloads no longer “pretty”


in express 3.x I did

res.send(200, {
    foo : 'bar'

return “pretty” JSON, in the browser and also in tools like Postman.

in express 4.x I do

res.set('Content-Type', 'application/json');
res.send(200, {
    foo : 'bar'

and JSON is not formatted anymore.

Checked headers, content type header is set correctly.

Is there any way to return to the old formatted way?


Author: Fantashit

2 thoughts on “JSON payloads no longer “pretty”

  1. For anyone else looking at this, app.set(‘json spaces’, 2); is the configuration required to send pretty json.

Comments are closed.