const DOMPurify = require('isomorphic-dompurify'); const txt = "Line 1\nLine 2\n\nLine 3\nBold text"; console.log(DOMPurify.sanitize(txt));