html-beautifydeprecated

Inserts spaces and line breaks into html string.

Usage no npm install needed!

<script type="module">
  import htmlBeautify from 'https://cdn.skypack.dev/html-beautify';
</script>

README

alt tag

How it work?

Inserts spaces and break lines into html string. It looks like this:

<!-- Before -->
<div><p>Hello <b>world</b>!</p><p>How are you?</p></div>

<!-- After -->
<div>
  <p>Hello <b>world</b>!</p>
  <p>How are you?</p>
</div>

How to use?

import htmlBeautify from 'html-beautify'
htmlBeautify("<div><p>Hello <b>world</b>!</p></div>")
// => "<div>\n  <p>Hello <b>world</b>!\n  </p>\n</div>"

Also you can pass string with spaces and break lines, it will be remove it and add them again.