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.

Output

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.

Browse all tools