HTML & XML Formatter
Paste HTML or XML to indent it neatly, or minify it. HTML mode understands void tags and keeps pre, script and style content untouched.
- Choose HTML or XML and paste your code
- Pick an indent size
- Format or minify, then copy the result
Your files never leave your device
Formatting and minifying markup
Markup copied from a browser, an API or a build tool is often one long line. Paste it into the input box, choose HTML or XML, pick an indent size and press Format to get neat, indented code. Press Minify to do the opposite and remove comments and the whitespace between tags.
- Content inside pre and textarea tags is left exactly as it is, and script and style content is never treated as markup.
- Minifying removes comments and the whitespace between tags. Whitespace between inline elements can matter in HTML.
- In XML mode an error message appears if the document is not well-formed.
A worked example
Paste <ul><li>One</li><li>Two</li></ul> in HTML mode with an indent of 2 spaces. The result is four lines: the ul tag, then each li element indented by two spaces, then the closing ul. Press Minify on that result and you get the single line again.
In HTML mode, tags such as br and img that need no closing tag are understood, so they do not push the following lines further to the right. In XML mode every tag must be closed, and a missing one produces an error message.
What to check afterwards
The formatter changes whitespace only. Browsers treat a line break between two inline elements, such as two links, as a space, so a formatted page can show a small gap that was not there before. Look over important pages after formatting or minifying.
It does not repair broken markup. If a tag is missing in HTML, the code is formatted as given, so use a validator when the page looks wrong. Keep a copy of the original before replacing a file with minified code.
Frequently asked questions
What is the difference between HTML and XML mode?
HTML mode knows tags like br and img that need no closing tag. XML mode treats every tag as strict and reports an error if the document is not well-formed.
Will formatting change how my page looks?
Rarely. Added line breaks can add small spaces between inline elements, so check important pages after formatting.
Does it fix broken HTML?
No. It formats what you give it and keeps unknown parts as they are. Use a validator to find structural mistakes.
Can it handle large files?
Yes, as long as your browser has enough memory. Very large files may be slow.
Does minify remove comments?
Yes. Comments between tags are removed, while pre and textarea content is kept exactly. Script and style blocks are not parsed as markup, so a comment written inside them stays.
Is my code uploaded?
No. Everything happens on your device and your code is never sent anywhere.