InTab

HTML Formatter

Indent and tidy HTML, or minify it for production.

Formatters: Pretty-print, minify, validate and compare. It runs in your browser, so nothing you enter is uploaded.

What it does

The HTML Formatter indents HTML so that nested elements line up and the structure is easy to follow. It can also minify HTML for production, removing comments and the whitespace between tags while leaving <pre>, <textarea>, <script> and <style> blocks exactly as written.

How to use it

  1. Paste HTML into Input, or click Sample.
  2. Click Beautify to indent, or Minify to compress.
  3. When beautifying, choose the indent and tick Wrap long attributes to put each attribute of a long tag on its own line.
  4. Copy or download the result.

Example

<ul class="nav"><li><a href="/">Home</a></li><li><a href="/tools">Tools</a></li></ul>

Beautified:

<ul class="nav">
  <li><a href="/">Home</a></li>
  <li><a href="/tools">Tools</a></li>
</ul>

Good to know

  • Beautifying keeps everyday HTML as it is, including tags without a closing tag such as <br> and <img>.
  • Minifying removes normal comments but keeps conditional comments (<!--[if …]>).
  • Whitespace between inline elements can matter: <b>a</b> <i>b</i> shows a space between the words. Check the page after minifying if spacing looks different.

FAQ

Does it fix broken HTML? It re-indents what is there but does not add missing closing tags. Browsers are forgiving, so check the result in a browser.

Can it format the CSS and JavaScript inside the page? Inline <style> and <script> blocks are indented along with the HTML. For a full clean-up, use the CSS Formatter and JavaScript Formatter.

More Formatters tools

  • JSON Formatter: Beautify, minify, validate and sort JSON. Handles escaped/stringified JSON.
  • XML Formatter: Beautify, minify and validate XML documents.
  • SQL Formatter: Format SQL for MySQL, PostgreSQL, T-SQL, SQLite and more.
  • Diff Finder: Compare two texts or JSON documents line by line or word by word.
  • Text Diff Checker: Paste two versions of a text and see exactly which words changed.
  • JSON Validator: Check JSON is valid and see the exact line, column and a fix hint when it is not.
  • JavaScript Formatter: Beautify minified or messy JavaScript with your choice of indentation.
  • JavaScript Minifier: Minify JavaScript with Terser: compress, shorten names and see the size saved.
  • CSS Formatter: Beautify CSS with one rule per block and consistent indentation.
  • CSS Minifier: Minify CSS with CSSO: remove whitespace, merge rules and shorten values.
  • YAML Formatter: Validate and re-indent YAML, keeping comments, with optional key sorting.