Home » Nodejs » How can express and jade does not compress html?

How can express and jade does not compress html?

Posted by: admin November 30, 2017 Leave a comment


I using express and jade, but when I debug I doesn’t want jade compress my html, are there any way to pass an option jade globally and make it does not compress html.


In the time since this answer was written an option has been added to control this behaviour.

app.locals.pretty = true;

At the moment, no. This feature has been discussed here:


The html doesn’t actually get compressed or minified by default, though. It’s just not formatted nicely. The simplest way I’ve found to make it human-readable is to use Chrome’s dev tools, which give you a nice foldable representation of the source.


If you use Express 3.x, you can control compression via app.locals.pretty. I usually enable it while development:

app.configure('development', function () {
    app.locals.pretty = true;


You can use Jade Comments to annotate your code for viewing in the browser.

h1 Some Title
p some content

will output

<h1>Some Title</h1>
<p>some content</p>

The template is already compiled once it leaves the server, so if you wanted to view the template in the browser you would have to write a plugin that de-compiles html to jade and than display the decompiled version.


Huh, new to nodejs so maybe missing something here; but in app.js adding app.set('view options', {pretty: true}); was ineffectual (using express 3.0.3).

..doesn’t appear to be supported? did find a workaround, e.g. on a per route basis:

exports.index = function(req, res){
  res.render('index', {
    [... other stuff ...]
    pretty: true