sublime text 2 - way to unminify or beautify HTML
Asked Answered
F

2

17

I'm finding myself pasting in a tonne of code that is minified, i,e all on one line.

Rather than scanning through it manually and adding in linebreaks to make it readable, is there an option in Sublime to do it, or a plugin?

For example, I have this (although much longer):

<html><head><title>some title</title></head><body><div><span>some content</span></div></body></html>

And I want to end up with this, without spending half an hour pressing enter on my keyboard:

<html>
  <head>
    <title>some title</title>
  </head>
  <body>
    <div>
      <span>some content</span>
    </div>
  </body>
</html>
Faenza answered 19/11, 2012 at 13:48 Comment(1)
This works pretty well: procssor.comMalorie
J
15

If you have the Package Manager installed in you can install the Tidy HTML package.

Josefajosefina answered 19/11, 2012 at 13:57 Comment(2)
I installed tidyHtml, but unsure what command to use. reindenting still doesnt seem to do anything. in the meanitime, highlighting a close angle bracket and putting a cursor at each one (ctrl+cmd+g) and adding a line break seems to work best.Faenza
With the HTML file open, Ctrl+Shift+P, then start to type Tidy HTML. If it was installed correctly it should be the only menu option remaining. Click on that.Josefajosefina
S
15

Tidy HTML for Sublime Text 2

HTML-CSS-JS Prettify for Sublime Text 3

Streetwalker answered 29/5, 2014 at 12:46 Comment(2)
Thanks! HTML-CSS-JS Prettify worked great for me. Note that HTML-CSS-JS Prettify requires node.js to be installed.Byandby
Thank you! Perfectly prettified a minified script without any error using Sublime-HTMLPrettify.Stull

© 2022 - 2024 — McMap. All rights reserved.