Skip to content
LINEZOVA
LINEZOVA / Free tools

HTML / CSS Formatter

Format HTML or CSS source locally with indentation and downloadable output.

Input & settings

What this tool does

HTML / CSS Formatter rewrites spacing. HTML is parsed with the browser’s HTML parser and then written back as indented tags. CSS is indented around braces and semicolons. Compact whitespace collapses line breaks. The output is placed in a text box. It is not inserted into this page and it is not a sanitizer or a standards validator.

How to use it

  1. Choose HTML or CSS and an indent of 2 or 4 spaces.
  2. Paste the source.
  3. Choose Format source or Compact whitespace, then copy or download the text.

Practical example

A single-line main element with a heading and paragraph is split onto indented lines. A CSS rule and a media query are split so each declaration sits on its own line.

Tips

The HTML parser can add implied elements or rewrite markup. A full document keeps a doctype line. A fragment is formatted from the body contents. Review the result before you replace a source file. The limit is 500,000 characters.

Questions

Will a script in the source run?

No. The source is parsed for formatting and the result is shown as text. Do not treat that as a security filter.

Does formatting prove the code is valid?

No. CSS is indented by a brace scan, not a full CSS validator. HTML follows the browser parser, which repairs many mistakes.

Are comments kept?

HTML comments are written back. CSS comments are kept while the brace scan runs.

Can external images in the markup load?

The formatter does not render the markup, so it does not request images or style sheets from it.

What does compact whitespace do?

It replaces line breaks with spaces and collapses repeated spaces. It does not rename or remove tags.

Related tools