No signup, runs in your browser

Free HTML formatter and beautifier

Paste your HTML and press Format HTML: each tag is indented by how it nests, and the CSS in <style> and the JavaScript in <script> are formatted too. Minify it to one line when you ship it. Your browser does the formatting, so your code is never sent to a server.

Formatting runs in your browser. Your code isn't sent anywhere.

Indent

How to format HTML

  1. Paste your HTML into the box above.
  2. Pick an indent: 2 spaces, 4 spaces, or a tab.
  3. Press Format HTML. Each tag is indented one step deeper than the tag it sits in, and the CSS and JavaScript inside are laid out line by line.
  4. Press Copy and paste the result back into your file.

What does formatting change?

Only whitespace: the line breaks and indentation between tags, and in the CSS and JavaScript. Tags, attributes, and text stay as they are, and the content of <pre> and <textarea> is left exactly as written.

How do I format HTML in VS Code?

Open the file and press Shift + Alt + F (Shift + Option + F on a Mac) to run Format Document. VS Code's HTML formatting is built on js-beautify, the formatter this page runs too. On a phone, or on a computer without an editor, paste the code here.

Should I indent with 2 spaces, 4 spaces, or tabs?

Use what your project already uses. With no rule to follow, take 2 spaces: Google's HTML/CSS style guide asks for 2 spaces and no tabs.

How do I minify HTML?

Press Minify. Comments and the whitespace a browser doesn't draw are removed, and the CSS in <style> is compacted. One space stays wherever words or inline tags meet, so nothing runs together, and <pre> and <textarea> keep their content. The size under the result shows what you saved.

Is my code uploaded?

No. Formatting and minifying run in your browser. Your code reaches Convika only when you press Publish as a link and then Get my preview link in the publish tool.

See the formatted page

Press Preview in the HTML viewer and the formatted code opens in Convika's HTML viewer, with its CSS and JavaScript running, on a phone or a computer.

Open the HTML viewer

Publish the formatted HTML

Press Publish as a link and the code goes into the paste box of the HTML publish tool. Press Get my preview link there for a private link that works for 3 minutes, with no signup.

Publish HTML for free

Guides

See all guides