HTML Formatter
Format HTML markup.
About this tool
Paste compact HTML and get it back with each block element on its own line and nested indentation. Inline tags such as b, a and span stay with their text, and the contents of pre, script and style are kept as written.
How to use
How it works
The markup is tokenised into tags, text and comments. Block elements open and close indented levels, inline elements and text are gathered on one line, and a block that holds only a short run of inline content is collapsed to a single line. Void tags such as br and img need no closing tag.
Worked example
A list with a link
- Input
- <ul><li>One</li><li><a href="/b">Two</a></li></ul>
- Output
- <ul> <li>One</li> <li><a href="/b">Two</a></li> </ul>
- Walkthrough
- The list items are indented and the link stays inside its li.
Limitations
- It does not validate HTML or fix unclosed tags.
- Whitespace inside text is collapsed to single spaces, except in pre and textarea.
- Inline elements are never broken across lines.
Questions
Are pre and script contents changed?
Does it keep inline tags with text?
Will it fix broken HTML?
Is my HTML uploaded?
Features
- Nested indentation
- Inline tags kept together
- pre/script/style preserved
- Runs in your browser
Related resources
Guides and videos from around the web—opens on YouTube or the publisher’s site.
TypeScript in 100 Seconds
Fireship
Formatted code is easier to skim while learning typed JS.
Watch on YouTubeLearn JSON - Full Crash Course for Beginners
freeCodeCamp.org
Formatted JSON is easier to read once you know the structure.
Watch on YouTube
- Introduction to JSON Web Tokens
jwt.io
JWT structure for decoder and debugger pages.
- CSS
MDN
CSS reference for reading beautified stylesheets after a format pass.