Review a small HTML fragment without rewriting its content
Choose formatting for a readability task
The HTML workspace provides several different operations, and formatting is the choice for conservative source readability. It adds line boundaries at selected adjacent block-tag boundaries while preserving the source text, attribute spelling, comments and raw blocks. It is not an aggressive document repair service or a promise of beautifully indented output for every fragment. Start with a small synthetic example whose visible text matters. Compare the returned source with the original before replacing anything. Keep validation, preview, minification and static Pug conversion as separate operations with their own documented boundaries.
A useful example is a short card or announcement copied from a template into a review discussion. Its tags may be crowded onto one line, making neighboring sections hard to distinguish. Formatting can expose selected boundaries without changing the names or words inside the card. It does not decide whether the card uses the right heading level, has sufficient contrast or belongs in that part of a page. Those require review of the real context. The converter helps make source easier to inspect; it does not replace that inspection with an automatic approval.
Choose the operation explicitly in this workspace. The same source can be passed to different operations, but a formatted result does not mean that every structural rule has passed. If the problem is mismatched explicit closing tags, use the separate structure check. If the problem is how a fragment looks, the inert preview is intentionally incomplete and removes features rather than reproducing a production page. Do not combine those different conclusions into “HTML is valid and safe.” A useful workflow names which operation produced each result and preserves the original source alongside it.
Compare a two-paragraph example
Checked synthetic input
<div><p>Hello</p><p>World</p></div>Exact observed output
<div>
<p>Hello</p>
<p>World</p>
</div>The worked fixture contains a div with two paragraphs, Hello and World, all on one line. Formatting inserts a newline between the adjacent opening div and first paragraph, between the two paragraph blocks, and before the closing div after the final paragraph. It does not insert spaces into either word. The exact input and result below show where the line boundaries appear. This makes the example reproducible and avoids implying a general indentation algorithm that the tool does not provide. The diagram separates tag boundaries from the text that must remain unchanged.
Now compare a paragraph with an inline span surrounded by spaces. The checked input <p>A <span>B</span> C</p> remains unchanged. Those spaces affect how the neighboring text reads, so a conservative formatter does not simply put every tag on its own line. An attractive source layout can otherwise change a rendered sentence if whitespace is altered carelessly. Retain a meaningful inline-text specimen when reviewing a formatting workflow. It provides a better regression check than a fragment made entirely of empty elements, where a whitespace error may not be visible at all.
A preformatted block with deliberate leading spaces and a line break also remains unchanged in the checked case. Raw script content is preserved as source rather than executed. That preservation is not a security endorsement of the content. If the source contains behavior you do not trust, formatting it does not make it suitable for insertion into a live page. Keep such text in an appropriate non-executing review surface. The exact source output is the deliverable of this operation; a screenshot alone cannot establish that every significant space or quote was preserved.
Understand the conservative implementation limits
The markup workspace bounds input at 100,000 UTF-16 code units, tokens at 10,000, nesting at 40 levels and output at 1,000,000 characters. Local text-file import has a separate 100,000-byte maximum. A token here is an implementation unit of markup or text, not a word count for documentation. A file can reach a byte limit before its displayed character count reaches the source limit. These limits support a bounded local tool; they do not describe the maximum document size supported by a browser or by another formatting library.
The formatter recognizes selected block-tag adjacencies rather than rebuilding a complete browser document tree. It preserves attribute quotes and comments instead of choosing a preferred spelling for every attribute. Unclosed comments, quotes or raw blocks can prevent processing. The tool does not automatically supply omitted end tags or resolve malformed nesting through a browser's recovery rules. A returned formatted string therefore is not a full HTML conformance verdict. Use the structural checker for its narrower explicit-tag checks, then use appropriate browser and application tests for questions outside that supported model.
Minification is a different operation and can involve different whitespace choices. Do not infer that a formatting result is minimized, compressed or faster to load. Similarly, formatting cannot prove accessibility, sanitize user content or determine whether links and remote resources are appropriate. The workspace's inert preview removes scripts, styles, media, forms, embedded content and resource-related attributes; it is a deliberately limited teaching view, not a screenshot of production behavior. Keep those distinctions in your notes so a teammate does not mistake a preview or a source transformation for a complete page assessment.
Use the output in a careful review loop
For a code review, retain the raw fragment and run formatting on a copy. Compare the text content, attribute values, comments and deliberately preserved spaces before accepting the result into your repository. Use a small example that includes the inline boundaries your component actually relies on. If a layout concern persists, inspect the real component with its actual CSS and surrounding markup. This tool does not load your stylesheets or apply a site's design system to decide whether a visual change is harmless. It supplies a bounded source transformation for the next review step.
For an educational example, show the unformatted input beside the exact returned source and explain which boundary was changed. Avoid suggesting that additional line breaks imply more semantic structure than the tags already expressed. A learner should be able to identify the same two paragraphs before and after processing. Copy and Download transfer generated output, but they do not update an editor or verify a destination file automatically. Check the receiving editor's line-ending and paste behavior if byte-exact comparisons matter to the task, and keep the original fixture available.
When a fragment fails, reduce it to the smallest non-sensitive specimen that still reproduces the problem. Keep the relevant quote, comment, raw block or nesting boundary intact. Do not repeatedly delete punctuation until a different fragment passes and then call that a repair of the original. Record what changed and run the appropriate checks on the actual final source. The useful outcome is a readable, faithfully preserved specimen with clear limits. A production release, complete validation and a security decision still require their own evidence and authorization.
Supporting reference: HTML context; conservative local formatter behavior described above.
Related existing tool: html structure checker.