Skip to content

HTML Formatter

Clean up messy or minified HTML in one paste.

Indent

Quotes

Everything runs in your browser. Nothing is uploaded.

More Developer Tools

All tools

How to use the HTML formatter

Three steps, all in your browser.

  1. 1

    Paste your input

    Type or paste your code or data. Press Sample to try an example.

  2. 2

    Pick the style

    Choose indentation or options. The result updates as you type.

  3. 3

    Copy the result

    Copy the output in one click. Nothing is saved or sent anywhere.

HTML Formatter: what to know

The HTML formatter runs Prettier, the open-source formatter used in many editors, in your browser. It indents nested elements, puts block elements on their own lines and wraps long attribute lists, turning minified or hand-mangled markup into something you can read and edit.

HTML is trickier to format than most languages because whitespace between inline elements is visible on the page: a line break between two links renders as a space. Prettier keeps that whitespace exactly as it was, which is why it sometimes breaks lines in unusual places, such as inside a closing tag. That's deliberate: the page renders the same.

Inline <script> and <style> blocks are formatted as JavaScript and CSS too. Template syntax from frameworks and server languages, such as Jinja, PHP or Handlebars, isn't plain HTML and may not format cleanly; format those in an editor with the matching plugin.

Popular uses

  • Reading the HTML of an email template or CMS export
  • Cleaning up markup before pasting it into a project
  • Unminifying a page's source to understand its structure
  • Making HTML snippets tidy for documentation

Tips for the best result

  • Paste a whole document or a fragment; both work.
  • If the output has an odd break like </a\n>, it's protecting whitespace; changing CSS display or removing the space in the source avoids it.
  • Use the HTML minifier for the opposite job, shrinking markup for production.

Read how JustYourDev works and our privacy details. Code, data and files you use here are processed in your browser and are never sent to our server.

Frequently asked questions

Prettier, the widely used open-source code formatter, running in your browser. Its HTML output is what many editors produce on save, so the result matches common project style.

Rarely, but it can. Whitespace between inline elements (such as two links side by side) is significant in HTML, and Prettier is careful to keep it, which is why some lines wrap in unexpected places.

No. Every tool runs in your browser, so your code, tokens, keys and files are processed on your device and are not sent to our server or stored. Reloading or closing the page clears them.

Yes. Every tool is free with no sign-up and no limits on use. Clearly labeled ads keep it that way.

Yes. The tools work in any modern browser on phones, tablets and computers, though large files and long code are easier to handle on a computer.