aicores.io

HTML Formatter

Paste your HTML below to prettify it with proper indentation, or minify it by removing extra whitespace.

About HTML Formatter

This free online HTML formatter lets you prettify and minify HTML code instantly in your browser. No data is sent to any server — everything runs locally. The prettifier adds proper 2-space indentation based on nesting level and places tags on separate lines for improved readability. The minifier removes unnecessary whitespace to reduce file size. A size comparison is shown so you can see the impact of formatting.

How to Use

  1. Paste or type your HTML into the input area on the left.
  2. Click Prettify to add proper indentation and newlines between tags.
  3. Click Minify to strip extra whitespace and compress the HTML.
  4. Check the size comparison below the textareas to see how the output compares to the original.
  5. Click Copy to copy the output to your clipboard.

Frequently Asked Questions

Does this tool fix broken HTML?

No, this tool formats the HTML you provide but does not attempt to fix missing tags, unclosed elements, or other structural issues. It works best with well-formed HTML.

How does prettify handle self-closing tags?

Void elements like <br>, <img>, and <input> are recognized automatically and do not increase the indentation level. Tags ending with /> are also treated as self-closing.

Is inline JavaScript or CSS preserved?

Yes, the content of script and style tags is preserved as-is. The formatter only adjusts whitespace between HTML tags and does not modify the content within them.

What indentation style is used?

The prettifier uses 2-space indentation for each nesting level. This is a widely adopted convention that balances readability with compactness.

Is my data safe?

Absolutely. All processing happens entirely in your browser using JavaScript. No data is uploaded to any server, so your HTML stays private.

Related Tools