About this tool
An HTML formatter converts cramped or inconsistently indented markup into a readable document. It uses Prettier's HTML formatting rules to organize elements, attributes, and line breaks. Developers can use it to inspect generated pages, unminify a copied template, or standardize markup before placing it back into a project.
Formatting takes place inside your browser, with no HTML uploaded and no copy retained after the tab closes. The formatter also handles CSS found inside style tags and JavaScript found inside script tags. Set the indentation and print width first, then review all three parts of a self-contained page in one formatted result.
How to use the HTML Formatter
- 1Paste the HTML document or fragment into the source editor.
- 2Choose spaces or tabs and set the indentation amount.
- 3Set the print width that should guide markup wrapping.
- 4Run the HTML formatter and inspect embedded style and script blocks.
- 5Copy the cleaned markup after confirming the document structure.
Features
Prettier HTML rules
Reprint valid markup with consistent nesting, attribute layout, spacing, and line breaks.
Embedded CSS formatting
Clean up stylesheet code placed directly inside HTML style elements.
Embedded script cleanup
Format JavaScript contained in script elements along with the surrounding markup.
Markup indent settings
Control whether nested elements use tabs or your selected number of spaces.
HTML print width
Guide line wrapping for long tags, attributes, and text structures with one setting.
Frequently asked questions
Can this formatter unminify an HTML file?
Yes. Paste valid minified markup and run formatting to add readable indentation and line breaks. Prettier may also reorganize attributes according to its HTML rules.
Will CSS inside a style tag be formatted too?
Yes. CSS inside style tags is formatted as part of the HTML document, using Prettier's embedded language support.
What happens to JavaScript inside script elements?
JavaScript in script elements is formatted along with the markup. This is useful for a single HTML document that contains its own behavior.
Can print width force every HTML line to be shorter?
No. It guides Prettier's wrapping decisions, but long text or values that cannot be split may extend beyond it.
Is pasted HTML sent to a server?
No. The formatter processes the markup locally, and nothing remains with the site after you close the browser tab.