How to beautify HTML online, free and private
An HTML beautifier takes minified or messy markup and puts it back into readable, indented lines. Here, paste your HTML into HTML Input and the indented version appears in Formatted Output as you type. Pick 2 spaces, 4 spaces or Tab under Indent, then click Copy Formatted or Download .html.
It runs in your browser; nothing is uploaded (you can check the Network tab in DevTools).
The beautifier changes whitespace and attribute quotes only. Line breaks and indentation go next to block elements and where your source already had whitespace; text is never reflowed; and the content of pre, textarea, title, script and style tags is kept as written. It does not repair invalid HTML or format the code inside script and style, so pair it with the CSS beautifier and the JavaScript beautifier. To go the other way, shrink the result with the HTML minifier.
Table of Use: common jobs and the setting to use
| Job | Setting | What you get |
|---|---|---|
| Read minified production HTML | Paste it; keep the defaults | Each block element on its own line, nested with 2 spaces |
| Match your projectโs indentation | Indent: 4 spaces or Tab | The same structure, indented with 4 spaces or one tab per level |
| Compare two versions of a file | Sort attributes alphabetically | class, id, name, type in the same order in every tag |
| Keep sections visually separate | Keep blank lines between elements | A blank line wherever your source had one or more, each run collapsed to one |
| Point to a line in a review or bug report | Show line numbers (on by default) | A number beside every output line, not included in the copy |
| Save the result as a file | Download .html | A file named beautified.html |
| Tidy one component, not a whole page | Paste the snippet | An indented snippet; no html, head or body tags are added |
Once the markup is readable, check how it renders in the HTML previewer, or compare two formatted versions with the text diff tool.
Features
- Formats as you type. There is no Format button. The output follows the input, and a deferred update keeps typing responsive on very large documents.
- Four options. Indent (2 spaces, 4 spaces or Tab), Sort attributes alphabetically, Keep blank lines between elements and Show line numbers.
- Whitespace-safe printing. Inline runs such as
<b>$5</b><i>.00</i>stay together, so no space appears between them. Attribute values are never edited, and a>inside a quoted value stays part of the value. - Hidden elements handled. Elements with the hidden attribute, a closed dialog or an inline style that floats, positions or hides them get their own line only where the source already had whitespace on both sides.
- Syntax colors and counts. Tags, attributes and comments are colored, and the line and character counts of input and output are shown. Colors switch off above 3,000 output lines to keep the page fast.
- Copy Formatted, Download .html, Clear. If the browser blocks clipboard access, the tool says so and you can select the output by hand.
- Private and free. No account, and nothing is uploaded or saved.
Need to format other languages? Use the XML formatter, the JSON formatter or the SQL formatter.
How to use the HTML beautifier
- Paste or type your markup into HTML Input. The box starts with a sample page; click Clear to empty it first.
- Under Formatting Options, choose Indent: 2 spaces, 4 spaces or Tab.
- Tick Sort attributes alphabetically or Keep blank lines between elements if you want them. Untick Show line numbers to hide the numbers.
- Read Formatted Output. The counts above each box show lines and characters for the input and the result.
- Click Copy Formatted to copy the result, or Download .html to save it as beautified.html.
- If your stylesheet makes block elements inline-block, floats them or sets white-space: pre on them, open the page afterwards and check it still looks right. Then minify it again for production if you need a smaller file.
Who can use it
- Front-end developers reading minified production HTML, or tidying a template before a code review.
- SEO and content teams inspecting copied page source to check title, meta and structured data tags, and then writing new ones with the meta tag generator.
- QA testers and support staff who need a readable snippet to attach to a bug report.
- Students and teachers showing how nesting works, one level per indent step.
- Writers and bloggers cleaning HTML exported from an editor, or moving it on with the HTML to Markdown converter.
FAQs
How do I beautify HTML online?
Paste your HTML into HTML Input. The indented version appears in Formatted Output straight away and updates as you type. Choose 2 spaces, 4 spaces or Tab under Indent, then click Copy Formatted to put it on your clipboard or Download .html to save beautified.html. Nothing is uploaded, because the formatting runs in your browser.
Will beautifying HTML change how my page looks?
Not with normal CSS. The tool adds line breaks and indentation only where browsers ignore whitespace, such as next to div, p, li and table, or where your source already had whitespace. Text is never reflowed and attribute values never change. The exception is a stylesheet that makes block elements inline-block, floats them or sets white-space: pre, so check those pages afterwards.
Why do some lines stay long after formatting?
Runs of inline content, such as a paragraph with links, bold text or images, stay on one line, because a line break between two inline elements shows up as a visible space. For example, a bold $5 followed directly by an italic .00 would render as "$5 .00" if split. Block-level children, by contrast, always get their own lines.
Does it format the CSS and JavaScript inside script and style tags?
No. That code is kept as written. A short one-line script or style goes on its own indented line, and multi-line code is left untouched, because re-indenting could change multi-line strings or template literals. To reformat the code itself, paste it into the CSS beautifier or the JavaScript beautifier.
Can I format an HTML snippet, or does it need a full page?
A snippet works. Paste a single div, a list or a table row and it is indented as it stands. The tool does not add html, head or body tags, and it does not close tags you left open. Nothing is added or removed apart from whitespace and attribute quotes, so errors stay visible. Use a validator such as the W3C Markup Validation Service to find them.
What does Sort attributes alphabetically do?
It reorders the attributes inside every tag from A to Z, ignoring case, so an input written with type, name and class comes out as class, name, type. Values are unchanged. Browsers do not care about attribute order in normal markup, but a consistent order makes two versions of a file easier to compare line by line in a diff tool.
Does the beautifier change quotes or tag case?
Attribute values are never edited, but quotes are normalized to double quotes where possible. If a value itself contains a double quote, the tool uses single quotes for that attribute. Tag and attribute names keep the case you wrote, so DIV stays DIV. Only whitespace and quote style change, which keeps the formatted file a faithful copy of your markup.
Is my HTML uploaded to a server?
No. Parsing and formatting run in JavaScript in your browser, so your markup is never uploaded (you can check the Network tab in DevTools). The tool does not save your input either: reload the page and the sample markup returns. It is free, with no account and no limit on how many times you use it.