Are there any JS scripts for formatting HTML code (i.e. tabs and everything else)? Example: I get the following markup through innerHTML:

<ul><li>1</li><li>2</li></ul>

And I want to make it readable (that is, indent):

 <ul> <li>1</li> <li>2</li> </ul> 

Yes, I forgot to say that I just need to output the HTML code formatted.

  • The question is not very clear. Give an example. - Zhukov Roman
  • why js script something? - thunder
  • Maybe it is better to use for this the capabilities of the editor / IDE in which you work? - Gena Tsarinny
  • 1. Example I get the following markup through innerHTML: <ul> <li> 1 </ li> <li> 2 </ li> </ ul> And I want to make it readable (that is, indent): <ul> <li> 1 </ li> <li> 2 </ li> </ ul> 2. Why? Because of the available funds there is only JS. - worialhat

1 answer 1

Here are a few options:

All three can format and highlight syntax in HTML and JavaScript. From the latter, you can tear out the code that is directly responsible for formatting HTML (file beautify-html.js)

  • Thank. To highlight JS, I already use CodeMirror. I did not know that there is a formatting in it. - worialhat