Sublime Text doesn't come with a built-in code beautifier but you can install one called
htmlprettify. To do this you will need to have already installed Package Control for Sublime.
From within Sublime, open the command palette by typing
P on Windows) and then type "install", hit enter when you see "Package Control: Install Package".
A window will appear – begin typing "htmlprettify" and when a matching result appears, hit enter to install the package.
Now you can highlight the code to prettify, right-click and select
HTML/CSS/JS Prettify > Prettify from the top of the menu.