Since there are lots of complains about js-beautify, I'm posting this alternative:
GIT: https://github.com/maxogden/commonjs-html-prettyprinter
DEMO: http://requirebin.com/?gist=45056f6a9b306a14ea3d
CODE:
var htmlmodule = require('html');
var str = ' \n \n Hello\n \n
\n ';
var pretty = htmlmodule.prettyPrint(str);
IF this does not work as you intend to, I recommend parsing the HTML string...
for this job you can use this xmldom parseFromString... it's really simple.