html-formatter Install npm i html-formatter Usage var formatter = require('html-formatter'); var html = '<!doctype><html><head></head><body></body></html>'; console.log( formatter.render(html) );