In an frontend application I have a string of JS code which I want to present to the user.

Currently it is formatted

<div class="foo"><div><span>Bar</span></div></div>

I am looking for an npm module which can process this string so that it looks like:

<div class="foo">

I have tested several HMTL prettifiers / beautifiers but none of them seem to do do the job of adding linebreaks where non existed before.

Does anyone have any recommendations?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.