How to trim whitespaces from JSON output in Node.js?

On Node.js using Express, I am outputting JSON with a simple response.send(myObject) It's working fine, but the response has a lot of white spaces indentations. Removing them reduces the size by half. Is there a quick/proper way to do this? I tried using JSON.stringify and it works great, but that turns the response type to text/html

a config setting was introduced in 3.0.0alpha1

try app.set('json spaces',0)

you can also compress your output which will remove uncessary whitespaces by gzipping it.

  app.use(express.compress());