About this tool
Paste a minified page or a template that has drifted out of shape and get properly nested, indented markup back, with any <style> and <script> blocks formatted too. It uses the Prettier formatting engine, loaded into your browser on first use, so the code is never uploaded. Whitespace handling can respect inline elements, never touch whitespace, or ignore it for the most compact layout.
How to use HTML Formatter
- Paste your HTML into the left box.
- Pick indentation and line width.
- Choose how whitespace around inline elements is treated.
- Copy the formatted HTML or download it.
Frequently asked questions
Why does the output wrap tags in unusual places?
With the default whitespace mode, the formatter avoids adding spaces between inline elements, because that would change how the page renders. Choose “Ignore” for a cleaner layout if spacing does not matter.
Can it fix broken HTML?
No. Unclosed or mismatched tags are reported as errors with a location so you can fix them first.
Does it work with templates such as Vue or Handlebars?
Plain HTML works best. Template syntax inside text is usually kept, but template-specific tags may be reported as errors.