HTML Formatter
Beautify, Minify And Check Your Markup
This tool for formatting HTML cleans up your code the way a browser would read it. An unclosed list item or a missing table cell is filled in rather than being rejected. In addition to correcting indents, quoting attributes, and closing implied tags, the tool also lists every correction made on its own line. Since everything occurs within this tab, no part of what you paste is ever uploaded and none of what you paste ever executes.
- FreePrice
- Beautify + minifyModes
- On its lineChecks
- NoneUploads
HTML Formatter
Beautify, minify and check HTML in your browser, with every issue on its line
- Elements
- 0
- Depth
- 0
- Size
- 0 B
Ready. Paste your HTML, open a file or try the sample.
| Result | Check | Details |
|---|
Run it on a test page before the live one
Keep a copy of your original code and try the result on a test page before you replace the live file. No automatic tool can see every way your site uses its code.
What an HTML Formatter Does for You
A browser will always display a Web page, even if there are errors on the page. So, when you have an unclosed paragraph, a list item without an ending tag, or a table cell that has been left open, they will be displayed by the browser. This occurs because the browser’s parser automatically corrects these errors as it parses the document. As a result, the HTML code used to create the live site is often less strict than what a developer would prefer to work with.
The purpose of the HTML formatter is to fill that gap. The HTML formatter reads your code as a web browser does, which means it will close any unclosed tags in your code, fix the indentation, align your attributes and return a file that you can read.
Along with the clean-up, it maintains a record of each of your choices. This includes such things as an implied end to a list, a void element written with a slash to indicate that it is closed, and a tag that does not have a matching partner, each being recorded into a check-off table along with its position within the document (i.e., line number and column number).
It builds no page and runs no script, so a block of markup copied from a client site is read exactly like your own. Moreover a <script> or a <style> block is carried across untouched, because its contents are not HTML and reformatting them would break them.
No other tabs will contain the content of this tab. So, if you have a template which is subject to an NDA, a partially complete component, or a page that you would not post publicly, they may be posted safely.
How An HTML Formatter Reads Your Markup
The first step in parsing is converting the text into tokens. There are many different types of tokens including start tags, end tags, runs of text, comments and the doctype. Each of these can be identified by the reader based on the next character that is encountered.
The second pass puts the tokens to create a tree. This is the stage where the shape of the document is checked against the rules of the WHATWG HTML parsing specification. This same specification is followed by every browser.
The order explains most of what the checks table says. Because some tags may be left open on purpose, a fresh <li> ends the one before it and a new row closes the last cell. So the tree the reader builds is tidier than the text you fed it.
Three kinds of element get special handling. First, a void element such as <br> or <img> never takes a closing tag. Second, a raw-text element such as <script>, <style> or <textarea> keeps its contents verbatim. Third, <pre> keeps its whitespace, because in that one element whitespace is content.
Case is a decision rather than a rule. By default the formatter leaves your tag and attribute names exactly as they are, so an inline <svg> keeps viewBox and linearGradient spelled the way SVG demands. Still, a single switch lowercases everything when you want the plainer HTML style.
Why Beautify And Minify Are The Same Reader
Both modes parse the XML identically and create the same document object model (DOM) tree. One mode formats the DOM tree into multiple lines using indentation, while the other strips out all whitespace between each tag.

So, the difference lies only in the final phase. Minifying will collapse run-of-the-mill white spaces rather than delete them. As such, a space that exists between two inline elements (tags) will remain because deleting that space would join those two words together when viewed by the user.
The common reader is what makes the check process similar in both modes. If there is a missing close tag, then it will be added when you format (beautify) or compress (minify) your code, and the error message will be displayed regardless of which mode you choose.
Basically, use a beautifier if you want to view or change your markup, and a minifier if you want to deploy it. The HTML Minifier (HTML Minifier), which will be used for pages you plan to serve, will perform the exact same type of compression with extra configuration capabilities.
The Checks It Runs, And What Each Note Means
The first note is an implied end tag. Because a <li>, a <p> or a table row may close itself, the formatter fills the end tag in and tells you where, so the tree is explicit even when your source was not.

The second is a void element written with an end tag. A </br> or a closing tag on an <img> means nothing, so the reader drops it and notes the spot rather than leaving a confusing pair.
An extra example of a non-matching end tag occurs when there is an end tag with no corresponding start tag. In this case, the reader does not attempt to guess what the user may have intended as a start tag, but rather finds the line containing the non-matching end tag.
The fourth is an element that never closes. If a <div> or a <span> runs to the end of the file still open, the note names the tag that started it, because that is the one you need to find.
The fifth is a duplicate attribute. If you have two class attributes in an HTML tag, then the browser will use the first one and ignore the second. So, the user is pointing out that there are two of them, and then the user can quietly change their styling.
The sixth stops everything, and it is the only one that does. A comment, a doctype or a <script> block with no end runs off the edge of the file, so the reader cannot finish and nothing is printed until you close it.
What This HTML Formatter Will Not Do
The markup will not load any images, run any scripts or apply any stylesheets. So, the markup will not be active on the tab when you are reading it.

It will not fully validate the markup. A formatter checks the shape, not the rulebook, so a <div> nested inside a <span> or a heading level skipped from two to four comes out neatly indented and still wrong. Neat code is not always valid code.
It won’t make changes to your code’s form. It adds an assumed close tag when reading the tree, and notes it, but it never re-writes your attributes or changes the order of your content.
It will not touch what is not HTML. The contents of a <script>, a <style> or a <pre> are copied across exactly, so run those through the JavaScript validator or the CSS validator when you want them checked too.
Using the HTML Formatter: A Short Video Guide
This brief video shows each step from start to finish. Choose your language below, and switch on captions if they help.
How To Format HTML With This Tool
Just four steps, and none of them asks you to sign up for anything.
Paste or drop the markup
So paste a whole page or one component, or drop a file on the box. Because the reader works on text, a fragment is fine and a full document is fine too.
Choose the indent, or minify, right here
Then choose two spaces, four spaces or tabs to beautify, or pick one line to minify. Since the same reader drives both, you can switch between them without pasting again.
Read the checks
After you scan the table that is located below the output. Since every row has a line and column, an unclosed implied tag or a dropped void close will be just one click away and not a search.
Copy, download or carry on
At last, you can either save what you created by downloading it as a file, or go directly to the top item in the list and correct it. When you have completed this step, the HTML will be ready to be placed into your editor, or onto the web page.
Reasons To Use This HTML Formatter
Five reasons, and each one saves a few minutes of squinting.
You always get output back
Because of HTML’s inherent forgiving nature, the reader corrects your imperfectly written code instead of rejecting it. Thus, you will get properly formatted output along with a series of comments, rather than receiving an error message and a blank screen.
It gives you the line and the column
A button will take you directly to each note’s info. A lengthy template is so a quick way to read, not a search.
It keeps your script and style blocks
The contents of a raw text element contain no HTML, so the formatter will simply copy these elements over as is. As a result, pages will appear orderly and will not damage the user’s Javascript.
Nothing uploads
All of the formatting occurs within this browser tab. So, if you were to copy and paste a page from a private repository or a client build into this tab, it would remain private.
Beautify and minify in a single tool
Since one reader drives both modes, you format while you work and minify when you ship, without a second tool or a second paste.
Habits That Keep Markup Tidy
Six habits that keep a page easy to read and quick to format.
- Close a tag as you open it So, the partner will be in place before filling out the middle. This is a simple practice, but it eliminates nearly all of the unclosed elements before they even occur.
- Quote every attribute value Unquoted values are fine until they come across a space or slash. At that point, the remainder of the value is absorbed. The use of quotation marks will prevent the formatter from having to add them on your behalf because the use of quotations ends the guessing process.
- Indent by nesting, not by eye The child tags are indented one level from their parents. Thus, the formatter can work out the layout that you intended, instead of using the indentation that was created by chance.
- Keep one block element per line Inline tags can share a line, but a section, a list or a table reads better stacked. So the tree on the page matches the tree in your head.
- Validate before you minify A minifier trusts its input, so a tag left open comes out open and harder to spot. Hence beautify first, read the checks, and only then shrink the file.
- Leave raw blocks to their own tools A script or stylesheet contained within your web page is not HTML. So, use a validator designed to check the syntax of scripts/stylesheets, instead of relying on an HTML formatter to parse and validate these types of files.
Six Ways Markup Trips People Up
Browsers will not stop any of these, so it’s so simple for a user to inadvertently send them out.
A list item that never closes
Watch out here. A
<li>closes itself when the next one opens, so the page looks right and the source hides how deep the nesting really goes.A closing tag added to a void element such as br or img
A
</br>or a closed<img>means nothing to a browser, so it is dropped silently. Because nothing breaks, the stray tag survives review after review.The same attribute used twice
A browser reads only the first
class, so when you write a duplicate attribute in your code, it may appear as though you wrote an incorrect selector when in reality you simply wrote a duplicate attribute.A block element placed inside an inline element
A
<div>inside a<span>renders, yet it is invalid and it confuses layout. So the markup can be perfectly indented and still wrong.A comment left open
A comment without a terminating character will consume the remaining content of the file. As such, all content following the comment will disappear from the output, and in this single instance, the formatter does not print anything.
A quote dropped inside an attribute
When there is a missing closing quote on an attribute’s value, the value will continue to the next attribute. This causes the tag to be viewed as a single, long value and so, the error will appear much further away from where you actually created it.
HTML Formatter Questions
Does this HTML formatter cost anything?
Yes, there is no need to make an account, you can use the product without limits, and there are no fees. You can format as many pages as you want.
Does the HTML I paste ever reach a server?
No. This browser tab does all the formatting. Your markup isn’t sent anywhere. Thus, any page with a confidentiality agreement will remain in its current location.
How does beautify differ from minify?
Both will interpret the markup similarly. The beautify option will print the tree vertically on indented lines to allow for easier viewing, while the minify option will print the tree horizontally without any indentation, allowing for a smaller file size.
Does it keep the spaces between my inline tags when minifying?
Yes. Minifying collapses runs of whitespace rather than deleting them, because a space between two inline elements is visible on the page and dropping it would join two words.
Will it touch my script and style blocks?
No. The contents of a script, a style or a pre element are copied across exactly, because they are not HTML and reformatting them would break them.
Why did it add end tags I never wrote?
Some tags (like list items and table rows) can remain open intentionally. Readers fill the missing end tag mentally, making the tag explicit.
Why did it remove a closing tag on my image?
A void element like an image or line break doesn’t need to have a closing tag. As such, when a void element has a closing tag, the closing tag is ignored by the reader, who then goes on to name the line.
Will it validate my HTML?
No. The tool verifies only how a page looks, not whether it meets all of the requirements in the rules, so a page may appear neat but may not meet the criteria to be valid. Validity and being neat/tidy are distinct issues.
Can it format a whole document, not just a fragment?
Yes, an entire web page (doctype, head, body format) and/or a single component will be formatted. Your line numbers are references to what you have given.
Does it keep the case of my SVG attributes?
Yes, by default. An inline SVG retains both the viewBox attribute and the linearGradient element, as SVG is case-sensitive and HTML is not. But if you would rather have all elements in lowercase, there’s a setting to do so.
Will it ever refuse to format?
The only times a comment, doctype, or an unclosed script block would cause the reader to stop reading are when the reader cannot work out where the block should have ended.
Does it work on Vue, Svelte or template files?
In general, yes. Framework-specific properties like bound values and/or directives will be maintained, as readers are generally accepting of property names. But if there is a lot of template-specific syntax, it will simply be interpreted as text.
Can I lowercase my tag and attribute names?
Yes, a switch will fold each of the tag and attribute names into lowercase, just like the typical HTML style. Your text and values are not affected by this change.
How do I jump to an issue?
Each note carries a line and a column, and a button scrolls the input to the first one. So you land on the character rather than on the area.
Is it possible to wrap long lists of attributes?
Yes, a switch breaks up an attribute-rich tag into multiple lines if the width of the line gets too large. This allows us to keep the width of a wide component in check, making it easier for users to read.
Is minifying here the same as the HTML minifier page?
Either way, the result is the same compact HTML. A dedicated HTML minifier gives a few extra features for a page that will soon be served, so use one before serving.
Does it count anything?
Yes. It reports the number of elements, the deepest nesting and the output size, which helps when you are checking whether a paste lost something.
Does it need an account or an extension?
No. There is no sign-up, no plugin and no extension. So you close the tab once the markup is tidy.
Will the HTML formatter work on my phone?
Yes. The panes stack one above the other and the notes wrap. A quick format can be done using a phone, but a longer file may be easier to complete using a keyboard.
What about my privacy?
The entirety of the process occurs in your browser, meaning that none of the HTML code will be saved or transmitted. If you wish to view how this works on your own machine, simply open up the page while having the network tab open.
More Developer Tools That Work Well With The HTML Formatter
Four pages the same job usually leads to.
- HTML minifier
When you’ve finished tidying up your webpage, make sure to compress it so that it’s ready for use on the web. As browsers download all bytes, you should also shrink (minify) the HTML code that you will be serving.
- HTML entity encoder and decoder
A formatter will leave your text as is, so if you are trying to display markup and not let the markup be rendered, convert the angle brackets to entities.
- XML formatter
The stricter form of the language is one in which a missing end tag is considered to be an error as opposed to simply a space that can be filled. So, use the proper reader for each type of document (i.e. feed, configuration file).
- Syntax highlighter
Once the HTML code is readable, you can then color it for a blog post or a presentation. Since the colors correspond to the tokens within the code, a clean-looking web page will highlight beautifully.
Tidy The Markup, Then Ship It
Paste your page, select either indent or minify, then refer to the notes at the bottom of the output. Your code isn’t run, and it isn’t uploaded. Many files will be formatted before the water being boiled, and the table lists all tags the reader had to close on your behalf.