TEXT & DEVELOPER TOOLS
HTML Formatter
Indent messy or minified HTML so the structure is readable, find unclosed or mismatched tags, or minify the markup for production.
Quick answer: Set the language to HTML, paste your markup or open a file, choose the indent size, and format, validate or minify it.
Use HTML Formatter ↓Loading the tool…
How to use HTML Formatter
- Set the language to HTMLThe same tool handles JSON and XML. Choose HTML to use the markup rules for void elements such as br and img.
- Paste or open your markupPaste a fragment or a whole page, or open an .html file. It is read locally.
- Format, validate or minifyFormat indents the tree, Validate lists structural issues, and Minify collapses whitespace and can strip comments.
- Copy the resultCopy the output, or use it as the new input to run another step.
About this tool
HTML copied from a browser, a CMS or an email template often arrives as one long line. Formatting it shows the nesting at a glance and makes it easier to spot a missing closing tag. This page formats and minifies HTML in your browser, so private templates stay on your device.
Common uses: Make HTML easier to review, compare, debug and hand off, or remove unnecessary whitespace before a simple delivery step.
Practical example: Format first while editing, validate the structure and only minify a reviewed document when the destination benefits from a smaller payload.
Important limitation: Formatting does not make unsafe HTML safe, and minification does not fix broken markup or application-level behavior.
Markup is processed in your browser tab and is not uploaded. Read the privacy information.
Formatting HTML safely
HTML is more forgiving than XML, so browsers quietly repair mistakes, and a page can look right while its markup is wrong. Validate lists issues such as a closing tag with no opening tag or elements left open. Fixing them helps with accessibility and search crawling, because parsers may repair the same page differently.
Be careful with whitespace-sensitive elements. Content inside pre and textarea keeps its spaces and line breaks, and inline text can change appearance if whitespace is added or removed between inline elements. Compare the formatted page with the original in a browser before you deploy it.
Minifying is for the file you serve, not the file you edit. Keep the formatted source in version control and minify as a final step. The tool shows how much smaller the markup became, but the saving is usually small compared with compressing images or enabling server compression.
Frequently asked questions
Can formatting repair invalid HTML?
It may report parser problems, but you still need to fix the underlying markup and test it in the target application.
Should I minify HTML during development?
Usually keep readable formatting while editing and minify only as part of a reviewed delivery process.
Is my text sent to a server?
Markup is processed in your browser tab and is not uploaded.
Does it format embedded CSS and JavaScript?
The surrounding markup is indented. Treat embedded style and script blocks as text and use a dedicated formatter if you need them restyled.
Will minifying break my page?
Normal markup is safe. Pages that rely on whitespace between inline elements, or on pre and textarea content, should be checked after minifying.
Can it fix invalid HTML for me?
It reports structural problems but does not rewrite your document. Correct the issues, then run it again.