Before and after
<ul class="nav"><li><a href="/">Home</a><li><a href="/docs">Docs</a></ul><p>Read the <a href="/guide">guide</a> first.<ul class="nav">
<li><a href="/">Home</a></li>
<li><a href="/docs">Docs</a></li>
</ul>
<p>Read the <a href="/guide">guide</a> first.</p>The unclosed <li> and <p> tags were closed where the browser would close them, and the link stayed inside its sentence.
What is preserved
- Whitespace that renders — text inside
<pre>and<textarea>is byte-for-byte unchanged. - Code —
<script>and<style>bodies keep their own line breaks and relative indentation. - Attributes — order, quoting and values are untouched; only extra spaces between attributes are collapsed.
- Comments and the doctype — kept when formatting, removed when minifying.
Related formatters
Formatting XML (sitemaps, RSS, SOAP)? Use the XML formatter, which also checks that the document is well-formed. For JSON, use the JSON formatter.