HTML Formatter
Make HTML source easier to read with consistent indentation and line wrapping. Spaces between inline elements can change sentence content, so formatting treats whitespace around every tag as significant. Input is processed as source text and is never rendered or executed as a preview.
Key features
- Choose 2- or 4-space indentation
- Set a preferred line width of 80, 100 or 120
- Use strict HTML whitespace handling and LF line endings
- Keep embedded-language formatting disabled for script and style
How to use
- Paste a complete HTML document or fragment.
- Choose indentation and a preferred line width.
- Run the formatter and inspect tag structure and whitespace.
- Copy the result, then separately test rendering, accessibility and script behavior in your own page.
Use cases
- Read an HTML template received on one line
- Standardize tag indentation before code review
- Prepare markup examples for documentation
Frequently asked questions
Can I preview the rendered page?
This tool formats source only and does not render input HTML. Script, iframe and image URLs in the input are not executed or loaded from that markup.
Why can a line exceed my chosen width?
Print width is a formatting preference rather than a hard character limit. Long URLs, attribute values and content that cannot be split without changing whitespace may remain longer.
Why are some tag boundaries wrapped unexpectedly?
The formatter uses Prettier’s strict HTML whitespace mode, which treats whitespace around every tag as significant. Tag boundaries are wrapped according to those rules. Actual page layout still needs separate testing.
Does it format JavaScript and CSS inside tags?
Embedded-language formatting is disabled, so script and style content is not separately reformatted. The containing HTML tags can still change. Use the dedicated JavaScript or CSS tool for minification.
Does a successful result prove the HTML is valid?
No. Formatting is not an HTML conformance, accessibility or security audit. Syntax the parser cannot handle produces an error, but a formatted result alone does not prove the page is correct.
What changes, and how much input is supported?
Input is limited to 100,000 UTF-16 code units. Indentation and source layout can change, and line endings become LF. Keep the original file and review output containing template-engine syntax.
Privacy
Input and results are processed in browser memory; this tool does not upload or store them. Reloading clears them. Site-wide advertising and analytics may operate separately, but tool usage events do not contain your input or output.
Comments & questions