Developer tools

HTML Formatter

HTML Formatter

Beautify messy HTML with clean indentation, or minify it for production.

About this tool

About HTML Formatter

View source on a minified page, copy markup out of a CMS or an email template, or open an exported HTML file, and you usually get one enormous line. Paste it here to get properly nested HTML: each block element on its own line, children indented, and the CSS inside <style> and the JavaScript inside <script> formatted as well. Choose 2 spaces, 4 spaces or tabs, wrap long lines at 80, 100 or 120 characters, and decide how attributes behave on long tags, from wrapping only when needed to one attribute per line. Inline elements such as links and bold text stay with their sentence, and <pre> and <textarea> content is never reflowed. Switch to Minify to remove comments and collapse whitespace for production, with an option to also minify inline styles and scripts. The formatter is built on the widely used js-beautify engine and runs entirely in your browser. Optional AI help can explain markup or repair broken HTML with your own AI key, sending only that HTML straight to your provider.

Built and maintained by Abhi JainUpdated

How to Format HTML

  1. 1

    Paste or open HTML

    Paste HTML into the left pane, open an .html file, or click Sample.

  2. 2

    Choose the style

    Keep Mode on Beautify and set Indent, Braces, Attributes and Wrap at, or switch Mode to Minify.

  3. 3

    Copy or download

    Copy the result or download it as an .html file.

HTML Formatter: questions and answers

Will beautifying change how my page looks?

In almost all cases, no. Browsers collapse whitespace between most elements. The exception is whitespace-sensitive content such as inline-block elements placed side by side, where a new line can add a small gap; <pre> and <textarea> are left untouched.

Does it format CSS and JavaScript inside the HTML?

Yes. Code inside <style> and <script> tags is indented with the same settings as the rest of the document.

Can it fix broken HTML?

It formats whatever you paste but does not repair missing closing tags. If indentation looks off from some point on, check that area for an unclosed element.

How do I unminify HTML?

Paste the minified HTML and keep Mode on Beautify. Line breaks and indentation are added back, though comments removed during minification cannot be recovered.

Is my HTML uploaded?

No. Formatting runs in your browser and nothing is sent to a server.

Can AI explain or fix my HTML?

Yes, optionally. Connect your own AI key in AI settings, then click AI to get a plain-language walkthrough of the markup or a minimal fix for unclosed and misnested tags. Only the HTML in the input is sent, directly from your browser to your provider.

Ready-made HTML Formatter presets