HTML Formatter
Beautify HTML — proper indentation, with embedded CSS and JS formatted too.
Runs in your browser — your data never leaves your deviceFree, no sign-up
Formatted HTML
The formatted HTML will appear here.
How it works
Your markup is processed by js-beautify — the library behind most beautifier tools, battle-tested for decades. Nested elements are indented one level deeper than their parents, attributes stay on their tag, and embedded <style> and <script> blocks are formatted with their language's own rules.
Text content and entities are never modified — only whitespace and line breaks change.
Features
- Language-aware: embedded CSS and JS formatted too
- 2 or 4 space indentation
- Optional line wrapping with a max line length
- Entities and text content preserved exactly
- 100% client-side — nothing leaves your browser
How to use
- Paste HTML, or upload a .html file.
- Choose indentation, line wrapping and empty-line handling.
- Press Format HTML, then copy the result or download it as a file.
Example
Input: <div><p>Hello</p><span>world</span></div>
Output: <div>
<p>Hello</p><span>world</span>
</div>Frequently asked questions
- Does it format the CSS and JavaScript inside my HTML?
- Yes. <style> blocks are formatted as CSS and <script> blocks as JavaScript — the formatter is language-aware and handles all three layers of an HTML document in one pass.
- Does the formatter validate my HTML?
- No — it is a formatter, not a validator. It re-indents and re-flows markup without checking tag structure, so unclosed or misnested tags are left as they are. Use it to make markup readable, not to check it is correct — for that, run your page through an HTML validator.
- What does the max line length option do?
- When set to a number greater than zero, long lines are wrapped at or before that column. Set it to 0 to disable wrapping entirely — every tag stays on the line the formatter puts it on.
- Are entities and special characters preserved?
- Yes. Entities like & and character references pass through untouched, and nothing is re-encoded. Your text content is exactly what you pasted — only whitespace and line breaks change.
- Is my HTML sent to a server?
- No. Formatting happens entirely in your browser with JavaScript. Nothing you type is transmitted anywhere — you can verify this in your browser's network inspector.