HTML Formatter

HTML Formatter beautifies minified or uneven HTML with consistent indentation and readable line breaks. It supports full HTML documents and fragments, including embedded JavaScript and CSS inside script and style elements.

Choose tabs or spaces, set a preferred line width, control HTML attribute wrapping, and decide how embedded script and style content should be indented. The formatter preserves template-friendly HTML and can keep existing newlines when they carry useful structure.

Use Preview to inspect the rendered structure without leaving the page. Preview scripts, forms, event handlers, and external resources are disabled for safety. Formatting, previewing, copying, and saving all run locally in your browser.

Code formatter FAQ

How do I format code on this page?

Paste code into the left editor or load a file, choose the options you need, and select Format. Review the result on the right, then copy or save it.

Why might the formatter report an error?

The input must match the selected language or syntax. Check incomplete statements, unmatched brackets or quotes, and a dialect or mode that does not match the input, then format again.

How does a code formatter work?

A code formatter reads language-aware tokens and nested structures, then rewrites indentation, spacing, and line breaks according to a consistent rule set. It does not compile or run the program, so formatting is not a correctness or security check.

Which settings are recommended for this language?

Two spaces with automatic attribute wrapping is a safe default. Use 80 columns for compact reviews or 100 for modern application markup. Control indentation, line wrapping, attribute wrapping, script and style indentation, preserved newlines, and inner HTML indentation. Preview shows the formatted markup safely.