๐ Runs in your browser โ nothing is uploadedโ Free, no signup
HTML Formatter & Beautifier
Paste messy or minified HTML to get clean, consistently indented markup โ or minify it to make it smaller.
0 characters
When should you use the HTML Formatter?
- Reading minified HTML copied from a page's source
- Cleaning up HTML exported from an email builder or CMS
- Shrinking an HTML template before shipping it
How to use the HTML Formatter
- 1
Paste your HTML
Paste a snippet or a full document into the input editor, or click Load sample.
- 2
Choose indentation
Pick 2 spaces, 4 spaces or tabs, and optionally wrap long lines.
- 3
Format or minify
Click Format HTML for readable markup or Minify for a smaller file.
- 4
Copy the result
Use Copy Output to copy the result.
Examples
One-line HTML to readable markup
Before
<div><p>Hi <b>there</b></p><ul><li>a</li><li>b</li></ul></div>
After
<div>
<p>Hi <b>there</b></p>
<ul>
<li>a</li>
<li>b</li>
</ul>
</div>Common errors and how to fix them
The indentation drifts further and further right- There's probably an unclosed tag such as a <div> without </div>. Find where the indentation stops returning to the left.
Text inside <pre> wasn't re-indented- That's intentional โ whitespace inside <pre> and <textarea> is shown on the page, so changing it would change what visitors see.
More from Code Formatters & Minifiers
Free tools that run in your browser โ no signup, nothing uploaded.
SQL Formatter & Beautifier
Format SQL queries for MySQL, PostgreSQL, SQL Server, SQLite and more.
CSS Minifier & Compressor
Optimize CSS by removing whitespace and comments to accelerate page load time.
JS Minifier & Compressor
Compress JavaScript to improve website speed and performance.
XML Formatter & Validator
Format, validate and minify XML, with errors shown by line and column.
Markdown Editor & Preview
Write Markdown with a live preview and copy the HTML.
HTML to JSX Converter
Convert HTML to valid React JSX โ className, style objects and more.
SVG to React Component
Turn SVG markup into a React component with camelCase attributes.
HTML to Markdown Converter
Convert HTML to clean Markdown, including tables and code blocks.
GraphQL Formatter
Format GraphQL queries, mutations and schemas with Prettier.
HTML Formatter FAQ
It re-indents HTML so each nested element sits on its own line at the right depth, making messy or minified markup easy to read and edit. The page renders exactly the same.
No. Only whitespace between tags changes. Content inside <pre>, <textarea>, <script> and <style> is kept as it is.
It removes comments and collapses runs of spaces and line breaks into a single space to make the file smaller. It keeps one space between tags so inline elements like <b> and <i> don't run together.
Yes. Embedded <style> and <script> blocks are indented along with the HTML. For large stylesheets or scripts, use the CSS Minifier or JS Minifier, which can also beautify.
No. It formats what you give it but doesn't close missing tags or repair invalid markup. Unclosed tags can make the indentation look uneven, which is a useful clue to where the problem is.
No. Formatting and minifying run in your browser, and nothing is sent to a server.
