Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sublime text 2 - way to unminify or beautify HTML

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>
like image 377
totallyNotLizards Avatar asked Nov 19 '12 13:11

totallyNotLizards


People also ask

How do I add prettier to Sublime Text?

I'll show you how to integrate Prettier into my favorite text editor, Sublime Text. Search for Prettier and you should see jsPrettier as one of the first options click on that to install it. Open Preferences>Package Settings>JsPrettier>Settings - Default and set the auto_format_on_save option to true .

How do I align HTML code in Sublime Text 3?

One option is to type [command] + [shift] + [p] (or the equivalent) and then type 'indentation'. The top result should be 'Indendtation: Reindent Lines'. Press [enter] and it will format the document.


2 Answers

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

like image 195
garyh Avatar answered Sep 23 '22 07:09

garyh


Tidy HTML for Sublime Text 2

HTML-CSS-JS Prettify for Sublime Text 3

like image 45
Fatih Hayrioğlu Avatar answered Sep 21 '22 07:09

Fatih Hayrioğlu