regula.tools
100% Client-SideFormatters

Online HTML Formatter, Minifier & Tag Validator

Format messy HTML templates, minify production markup, and catch unclosed or mismatched HTML5 tags off the main thread inside a dedicated Web Worker. Preserves `<script>`, `<style>`, `<pre>`, `<textarea>`, and HTML comments while supporting 2-space, 4-space, or tab indentation.

Loading workspace...

#How to Use This Tool

1Paste or type raw HTML into the input editor (or click "Load Sample").
2Select "Beautify" with 2 spaces, 4 spaces, or tabs—or switch to "Minify" to strip comments and inter-tag whitespace.
3Inspect the HTML5 Structural Tag Validation panel for a clean pass or line-numbered tag balance diagnostics.
4Copy the syntax-highlighted output, download a `.html` file, or share a compressed Mode B URL.

#Mathematical Formula & Standards

The engine tokenizes HTML5 markup into declarations (`<!DOCTYPE>`), comments (`<!-- -->`), raw text blocks (`<script>`, `<style>`, `<pre>`, `<textarea>`), opening tags, closing tags, and text nodes. A stack-based validator pushes non-void opening tags alongside their 1-based line number and pops matching closing tags, flagging unclosed, unexpected, mismatched, or void-element closing tags (`</br>`, `</img>`) immediately.

#Edge Cases & Technical Considerations

HTML5 Void Elements

Self-contained HTML5 void elements (`<meta>`, `<link>`, `<img>`, `<br>`, `<hr>`, `<input>`, `<source>`, `<wbr>`) never require closing tags and do not trigger unclosed-tag warnings.

Raw Content Elements (<pre>, <script>, <style>)

Whitespace and `<` / `>` operators inside `<script>`, `<style>`, `<pre>`, and `<textarea>` blocks are preserved verbatim without breaking tag balance or indentation.

Conditional Comments in Minify Mode

Standard HTML comments (`<!-- ... -->`) are stripped during minification to reduce payload bytes, while legacy conditional comments (`<!--[if ...]>`) are preserved.

#Frequently Asked Questions

Q:Does this tool detect unclosed or mismatched HTML tags?

Yes. The stack-based structural validator tracks every non-void opening tag and its line number, reporting unclosed tags, unexpected closing tags, mismatched nesting, and invalid closing tags on void elements.

Q:Will minifying HTML break <pre> or inline <script> blocks?

No. Raw text blocks (`<pre>`, `<textarea>`, `<script>`, `<style>`) are tokenized atomically so their internal whitespace and code remain intact.

Q:Is my HTML template uploaded to any server?

Never. Formatting and validation run 100% locally inside a browser Web Worker.

Have feedback or feature requests?

Help us improve this utility. Share suggestions, report edge cases, or request new features directly.

Send Feedback