ToolStudio.es
Powered by Prettier

Format HTML online

Turn minified or messy HTML into clean, consistently indented code you can actually read.

Options
Input
Processed in your browser: your code is never uploaded.
Result

Why format HTML?

HTML copied from a web page, exported by an editor or produced by a minifier often arrives as one endless line or with indentation that makes no sense. Finding a missing closing tag or understanding how a component is nested is painful in that state. Formatting rewrites the code with one element per line and an indentation that follows the structure of the document.

This tool uses Prettier, the most widely used code formatter, so the output looks like what you would get in a well-configured editor. You choose the indentation (2 spaces, 4 spaces or tabs) and the line width (80, 100 or 120 characters), after which long tags and attribute lists wrap onto several lines. The CSS inside <style> and the JavaScript inside <script> are formatted too.

Formatting only changes whitespace and line breaks; elements, attributes and text stay the same. Keep in mind that in HTML whitespace between inline elements can be visible, which is why Prettier is careful about where it breaks lines and sometimes keeps tags on the same line. If the HTML has a syntax error that the parser cannot handle, you get the error message with its position.

Formatting happens in your browser and the code is not uploaded. Your free account comes with 20 gift credits for any tool, and each file or pasted text costs 1 credit. You can re-process the same text with different options as many times as you like without paying again. With the gift credits you process one file per use; if you buy credits you can process several at once (each file is paid), and ToolStudio Pro gives you unlimited use of every tool, batch processing (several files at once, downloaded together in a ZIP) and no ads. You can cancel anytime.

How to format HTML

  1. Paste your HTML or drop an .html file.
  2. Choose the indentation: 2 spaces, 4 spaces or tabs.
  3. Pick the line width: 80, 100 or 120 characters.
  4. Run the formatter, then copy or download the clean HTML.

When an HTML formatter helps

  • Reading minified HTML from a production site.
  • Cleaning up markup exported from page builders or email editors.
  • Debugging nesting problems and unclosed tags.
  • Normalising indentation before a code review or a commit.
  • Preparing HTML examples for documentation or a tutorial.

Formatting vs minifying

They are opposite operations on the same code. Formatting adds whitespace to make HTML readable while you work on it; minifying removes it to make the file smaller for production. A common workflow is to keep the formatted version in your project and minify only what you publish.

Frequently Asked Questions

Does formatting change my HTML?

Only whitespace and line breaks. Elements, attributes and text are kept as they are.

Can it beautify minified HTML?

Yes. Paste the minified code and it comes back indented, with the embedded CSS and JavaScript formatted as well.

Tabs or spaces?

Both are supported. Choose 2 spaces, 4 spaces or tabs to match your project.

Is my code uploaded?

No. Prettier runs in your browser.

Is it free?

Your free account comes with 20 gift credits, and each file or pasted text costs 1, and you can re-format it with other options. For new input you can buy credits or go ToolStudio Pro, which gives unlimited use, several files at once in a ZIP and no ads.

Related tools

Development

HTML Minifier

Minify HTML online, including inline CSS and JavaScript, and see how many bytes you save. Runs in your browser.

HTMLMinify
Try this tool
Development

CSS Formatter

Format minified or messy CSS, SCSS and Less into clean, indented code with Prettier. Runs in your browser.

CSSSCSSLessBeautify
Try this tool
Development

JavaScript Formatter

Format and unminify JavaScript, JSX and JSON with Prettier: indentation, quotes, semicolons and trailing commas. Runs in your browser.

JavaScriptJSJSONBeautify
Try this tool
Development

HTML to Markdown Converter

Convert HTML to GitHub-Flavored Markdown with tables, task lists and code blocks. Choose heading and list style. Runs in your browser.

HTMLMarkdownMD
Try this tool
Featured on TinyShelfLaunched on StartupBaseFeatured on BuildlistToolStudio — Featured on CLAPSTORMFeatured on TheSaaSDirFeatured on DodoDirectoryFeatured on SumoDirFeatured on SaaSBisonFeatured on ToolcurioFeatured on Gets.ToolsFeatured on DailyPingsLaunching Soon on Uneed