# HTML Formatter

> Reindent HTML with consistent nesting while keeping script, style, and pre bodies untouched. Choose 2/4-space or tab indentation; runs privately in your browser.

[bfotkit](/) Runs in your browserCategories ▾[All tools 307](/en/tools/)[Text tools9](/en/tools/text-tools/)[Image tools27](/en/tools/image-tools/)[PDF tools20](/en/tools/pdf-tools/)[Social media tools97](/en/tools/social-media-tools/)[Security tools8](/en/tools/security-tools/)[Coding tools25](/en/tools/coding-tools/)[CSS tools12](/en/tools/css-tools/)[Color tools6](/en/tools/color-tools/)[Miscellaneous tools103](/en/tools/miscellaneous-tools/)

[All tools ↗](/en/tools/)[EN](/en/tools/html-formatter/)[PT](/pt-br/ferramentas/formatador-html/)[DE](/de/werkzeuge/html-formatierer/)[ID](/id/alat/pemformat-html/)[RU](/ru/instrumenty/formatirovshik-html/)

CODING & JSON · BFOTKIT

# HTML Formatter | BFOTKit

Reindent HTML with consistent nesting, so templates, email files, and copied markup become readable again. Inline script and style bodies are preserved untouched.

InputIndent2 spaces4 spacesTab

Load sampleFormat

OutputCopyDownloadClear

All processing happens in this browser tab. Nothing is sent to a server.

GUIDE

## How to format HTML

### How the reindentation works

The formatter walks the markup tag by tag: each opening tag starts a new line and increases the nesting level, each closing tag reduces it, and void elements such as br, img, input, meta, and link stay on one line. Text between tags is trimmed and placed on its own line, so a paragraph that was wrapped over three source lines becomes one readable line.

### Script and style bodies are left alone

JavaScript inside script tags and CSS inside style tags are emitted exactly as they appear, because reindenting them with the same rules as markup would corrupt code. Format those blocks separately with the JavaScript or CSS formatter tools if you need them tidy.

### Pick the indentation your project uses

Two spaces is the most common HTML convention; four spaces appears in older codebases and some style guides; tabs let each developer choose the display width. Match the file you are editing rather than mixing styles inside one template.

### Formatting is cosmetic, not validating

The formatter does not repair broken markup: an unclosed div will still be unclosed, just at a visible indentation level. That visibility is often enough to spot the missing tag yourself. It also does not add or remove attributes or reorder anything.

HELP / FAQ

## HTML formatter questions

### Will it change how my page renders?

It should not. Indentation between tags does not affect rendering except inside pre-like elements; the tool keeps pre, script, and style bodies untouched. Always paste back into your project and check the diff before committing.

### Does it handle conditional comments?

Yes. Conditional comments and regular comments are preserved as-is at their current nesting level, because they often carry meaning for older browser support.

### Can I format fragments without html tags?

Yes. The formatter works on any markup fragment: a div, a list, a form. Nesting is computed from the tags present, so a fragment indents correctly without a full document wrapper.

### Is my HTML uploaded anywhere?

No. Formatting runs in this browser tab and the download is generated locally. Nothing is transmitted to a server.

EXPLORE BY CATEGORY · BFOTKIT

## More tools like this

Pick a category to see every tool in it — then open one and discover related tools.

[All tools 307](/en/tools/)[Text tools 9](/en/tools/text-tools/)[Image tools 27](/en/tools/image-tools/)[PDF tools 20](/en/tools/pdf-tools/)[Social media tools 97](/en/tools/social-media-tools/)[Security tools 8](/en/tools/security-tools/)[Coding tools 25](/en/tools/coding-tools/)[CSS tools 12](/en/tools/css-tools/)[Color tools 6](/en/tools/color-tools/)[Miscellaneous tools 103](/en/tools/miscellaneous-tools/)

[Coding toolsPrivate JSON formatter and text cleanup tools↗](/en/tools/private-json-text-cleanup/)[Coding toolsURL Slug Generator↗](/en/tools/url-slug-generator/)[Coding toolsBase64 Encoder/Decoder↗](/en/tools/base64-encoder-decoder/)[Coding toolsURL Encoder/Decoder↗](/en/tools/url-encoder-decoder/)[Coding toolsHTML Encoder/Decoder↗](/en/tools/html-encoder-decoder/)[Coding toolsHAR Sanitizer↗](/en/tools/har-sanitizer/)[Coding toolsJSON Formatter↗](/en/tools/json-formatter/)[Coding toolsJSON Validator↗](/en/tools/json-validator/)

[Browse all tools →](/en/tools/)

[bfotkit](/)[All tools](/en/tools/)[Privacy Policy](/en/privacy-policy/)[Terms & Conditions](/en/terms-and-conditions/)[About Us](/en/about-us/)[Contact Us](/en/contact-us/)

Useful tools. No fuss. © 2026 BFOTKit[bfotkit.com ↗](https://bfotkit.com/)
