HTML formatter
Paste HTML that is minified, generated or just messy, and get neatly indented markup. <style> and <script> blocks are formatted as CSS and JavaScript as well.
How it works
-
Paste your code
Paste the code in the left box or open a file. No code to hand? Click Example.
-
Instant result
The result appears as you type. If there is an error, you see the line and character.
-
Copy or download
Copy the result with one click or save it as a file for your editor or project.
What does it do?
Every block element (<div>, <p>, <ul>, <li> …) goes on its own line, indented by how deeply it is nested. Inline elements such as <a>, <b> and <span> stay inside the sentence, so text still reads naturally. The formatter only changes whitespace between tags; your content and attributes stay exactly as they were.
Options
- Indent with 2 spaces, 4 spaces or a tab.
- Keep blank lines preserves at most one empty line where you had them, so your own grouping stays visible.
- Keep inline elements on the same line can be switched off to put every tag on its own line.
Formatting uses js-beautify, which runs in your browser; nothing is uploaded. For XML, which has stricter rules, use the XML formatter.
Frequently asked questions
Is the HTML formatter free?
Yes. The HTML formatter is completely free, with no account, sign-up or usage limit.
Is my code stored?
No. Your code is processed in your browser and is not sent to a server or stored.
Does it work on my phone?
Yes. The tool works in any modern browser on a phone, tablet or computer.