Client-side · Preserves Script/Style/Pre

Online HTML Formatter

Reformat HTML tags and structure

HTML Formatter

Waiting for input
Input HTML
Output (HTML)

Test Cases

Try HTML formatting examples

Load a case to replace the current input and inspect the output above. Examples are formatted as text in this page; they are not rendered as HTML or executed.

01 / HTML CASE

Nested HTML

<section><h2>Example</h2><ul><li>One</li><li>Two</li></ul></section>

✅ Tags receive two-space indentation and line breaks in this sample.

02 / HTML CASE

Embedded script

<div><script>const message="<tag>";if(message){console.log(message);}</script><p>Done</p></div>

⚠ JavaScript spacing and line breaks change. Formatting does not execute or validate the script.

03 / HTML CASE

Embedded style

<style>.card{color:red;padding:0 4px;}@media(max-width:600px){.card{display:block;}}</style><div class="card">Hello</div>

⚠ CSS is reformatted. Check selectors, cascade and the actual page after copying.

04 / HTML CASE

Preformatted text

<pre>  first
    second

  &lt;tag&gt;	end</pre><p>After</p>

✅ The inner spaces, tabs and blank lines in this pre block stay identical in this sample; surrounding markup changes.

05 / HTML CASE

Custom element

<user-card data-name="Ada"><span slot="name">Ada</span></user-card>

⚠ This short custom-element sample stays unchanged; component behavior and rendering are not tested.

06 / HTML CASE

Vue template

<template><my-card v-if="ready" :title="name"><span>{{ name }}</span><input v-model="name" /></my-card></template>

⚠ This template sample stays unchanged. The tool does not compile Vue or validate directives and expressions.

07 / HTML CASE

Unclosed tags

<div><p>Unclosed<span>text</div>

⚠ Output is produced without a validation error; the missing closing tags are not repaired.

08 / HTML CASE

Inline whitespace

<p><span>A</span><span>B</span> C</p>

⚠ This sample stays unchanged. Whitespace-sensitive layout still needs a browser check.

Compatibility observed in these examples

These results describe the exact examples above, not every document. Keep the original source and test the resulting page before publishing.

InputObserved result / limitation
Nested HTML✅ Tags receive two-space indentation and line breaks in this sample.
Embedded script⚠ JavaScript spacing and line breaks change. Formatting does not execute or validate the script.
Embedded style⚠ CSS is reformatted. Check selectors, cascade and the actual page after copying.
Preformatted text✅ The inner spaces, tabs and blank lines in this pre block stay identical in this sample; surrounding markup changes.
Custom element⚠ This short custom-element sample stays unchanged; component behavior and rendering are not tested.
Vue template⚠ This template sample stays unchanged. The tool does not compile Vue or validate directives and expressions.
Unclosed tags⚠ Output is produced without a validation error; the missing closing tags are not repaired.
Inline whitespace⚠ This sample stays unchanged. Whitespace-sensitive layout still needs a browser check.

Concept & Workflow

What Is an Online HTML Formatter?

Minified HTML fragments, CMS exports, and email templates are difficult to audit when collapsed onto a single line. This browser-local formatter restores clean hierarchical indentation while respecting <script>, <style>, and <pre> whitespace boundaries.

  • Preserves sensitive blocks: <pre> whitespace and inline script/style blocks remain intact without mangling.
  • Modern template friendly: handles custom Web Components and Vue template attributes cleanly.
  • Graceful error reporting: flags unclosed or mismatched tags without discarding your original markup.

How to Format & Inspect HTML Markup Online

  1. 1Paste raw HTML: enter your HTML snippet in the left editor, or load any of the 8 cases below.
  2. 2Check validation status: confirm the formatted status badge or review any mismatched-tag warning.
  3. 3Inspect indented output: review tag nesting, attributes, and inline whitespace on the right.
  4. 4Copy or download .html: copy the formatted markup or export index.html locally.

Documentation

HTML formatting: changes and limitations

Paste HTML or load a case below the editors to compare the source with two-space indentation and new line breaks. Copy the output or download index.html. Embedded JavaScript and CSS may also be reformatted.

The formatter processes source text, not a rendered page. A successful result does not validate HTML, repair missing tags, remove unsafe code or prove identical rendering. Keep the original and review the output before publishing.

Usage Boundaries & Limitations

  • Formatting changes whitespace and indentation; inline-element spacing can affect the displayed page.
  • The pre sample preserves its inner text, but one example is not a guarantee for all whitespace-sensitive documents.
  • Custom elements and Vue templates are text inputs, not compiled or tested components. Large input may block the interface while synchronous formatting runs.
What does this HTML formatter change?+

It adds indentation and line breaks to this page’s nested-HTML example. It also reformats embedded JavaScript and CSS. The compatibility table shows what happened in each sample.

Is an HTML formatter also an HTML validator?+

No. The unclosed-tags example returns output without a validation error and keeps missing closing tags. Use a separate HTML validator and test the page.

Are pre blocks and Vue templates guaranteed unchanged?+

No universal guarantee is made. The displayed pre content and Vue template stay identical in these samples; check your own document and use the Vue compiler for template validation.