HTML Validator
Validate HTML markup and get a list of errors with line references.
What is HTML Validator?
An HTML validator is a developer tool that parses an HTML document, checks the markup against the rules in the W3C HTML Living Standard, and reports every structural error it finds with a readable message. The validator does not render the page or execute scripts; it only inspects whether tags are balanced, attributes are well-formed, and the document tree is parseable by a conforming user agent.
This HTML validator runs the input through the browser’s native DOMParser, the same parser that Chromium, Firefox, and Safari use to build the document tree before painting. That means the validation matches how real browsers handle your markup, including the quirks of unclosed tags, nested block elements, and stray angle brackets. Frontend developers, QA engineers, and accessibility auditors use it to catch markup bugs before they cause layout glitches or screen-reader confusion in production.
Why use an HTML Validator?
- Catch structural bugs before deploy. Mismatched tags, missing closers, and orphaned attributes are flagged the moment you paste the markup, so they never reach a code review or a QA ticket.
- Verify accessibility-critical structure. Screen readers depend on a well-formed DOM. A misnested
<li>or an unclosed<button>can collapse the accessibility tree and break tab order for keyboard users. - Confirm cross-browser parseability. The validator uses the same WHATWG parsing algorithm as Chromium, Firefox, and Safari, so if it parses cleanly here, every modern browser will accept it.
- Debug template output fast. Drop the rendered output from a server-side template, JSX build, or static-site generator to confirm the framework emits well-formed markup before shipping a layout change.
- Stay private with internal markup. The HTML never leaves your browser. Pages with auth tokens, customer data, or unreleased copy stay on your device.
How to use the HTML Validator
- Paste your HTML into the HTML textarea. A full document or a single fragment both work.
- Click Validate to run the parser against the input.
- Read the result panel below the button. A green panel means the markup parsed cleanly; a red panel lists each error with the parser’s message.
- Fix the markup in the textarea and click Validate again to re-check. The previous result is replaced with the new run.
- Once the panel shows no errors, copy the cleaned markup into your codebase or template.
What gets checked
The validator runs the input through DOMParser in two modes. The first pass uses the HTML parser, which follows the WHATWG HTML Standard and surfaces fatal errors like an unclosed <script> or a malformed doctype. The second pass uses the stricter XHTML parser, which catches issues a tolerant HTML parser silently fixes, including unclosed void elements, mismatched casing in tag names, and unquoted attribute values that contain spaces.
| Check | What it catches | Example flagged input |
|---|---|---|
| Tag balance | Opening and closing tags must match | <div><p>text</div> |
| Attribute quoting | Attribute values with spaces or special chars must be quoted | <a href=/path with space> |
| Void elements | <br>, <img>, <input> cannot have closing tags | <br></br> |
| Doctype | Must be <!DOCTYPE html> for HTML5 | <!DOCTYPE HTML4> |
| Nesting rules | Block elements cannot sit inside inline phrasing | <p><div>text</div></p> |
| Stray characters | Unescaped <, >, or & in text content | <p>5 < 10</p> (should be <) |
The validator does not check WCAG accessibility rules, deprecated tags from HTML 4, or SEO-related signals like missing <title> or <meta description>. For those, run the markup through a dedicated accessibility checker like axe DevTools or a Lighthouse audit.
Common errors
<!-- Unclosed tag -->
<div>
<p>Paragraph one
<p>Paragraph two
</div>
<!-- Parser auto-closes the first <p> but flags the structure -->
<!-- Mismatched closing -->
<section>
<article>Content</section>
</article>
<!-- Error: section closed before article -->
<!-- Invalid nesting -->
<button>
<a href="/next">Click <button>nested</button></a>
</button>
<!-- Error: interactive content cannot nest -->Most parser error messages start with error on line N at column M, which maps directly to a row and column in your editor. If the message references “tag mismatch” or “premature end of data”, the fix is almost always a missing closing tag earlier in the document.
Common use cases
- Frontend developers shipping new components. Validate the rendered output of a new React or Vue component before merging to confirm no stray fragments slipped through.
- QA engineers reproducing layout bugs. Validate the live page source pulled from production to rule out malformed markup as a root cause of a visual glitch.
- Backend developers reviewing server-rendered templates. Drop the response body from a Rails, Django, or Hono endpoint to catch templating bugs that the browser would silently work around.
- Tech writers checking documentation snippets. Validate copy-paste-ready HTML examples in docs to make sure readers do not inherit broken markup.
- Accessibility auditors smoke-testing landing pages. Confirm the DOM is well-formed before running a full a11y audit; an unparseable page will give noisy axe results.
HTML Validator vs alternatives
| Tool | Best for | Offline | Cost | Limitations |
|---|---|---|---|---|
| W3C Nu Html Checker | Reference implementation, official messages | No | Free | Sends your markup to a server. |
tidy (CLI) | Batch validation in CI pipelines | Yes | Free | Less helpful error messages, dated rules. |
| Browser DevTools | Inspecting parsed DOM of a live page | Yes | Free | No explicit error list, silently fixes input. |
| VS Code HTMLHint | In-editor linting | Yes | Free | Misses some structural errors only the parser catches. |
| This HTML validator | Quick paste-and-check in a browser | Yes (runs in browser) | Free | Does not check WCAG or SEO rules. |
Frequently asked questions
Does this match W3C output?
The validator uses the same WHATWG HTML parsing algorithm that the W3C Nu Html Checker is built on, so structural errors line up closely. The error messages are worded differently because they come from the browser’s DOMParser rather than the Nu Checker’s bespoke output. For an officially branded W3C report, paste the markup into validator.w3.org/nu after this tester is clean.
Will this validator catch all HTML bugs?
It catches parser-level structural bugs, which is most of them. It does not catch semantic issues (using <div> where <button> belongs), deprecated attribute warnings, or accessibility violations like missing alt text. Pair this validator with axe DevTools or a Lighthouse audit for a full check.
Why does my fragment fail validation?
Some HTML fragments are only valid inside a specific parent. A <tr> outside a <table> will parse but trigger a structural warning. Wrap the fragment in its expected parent or paste it inside a minimal <html><body>...</body></html> shell before validating.
Does the validator follow HTML5 or XHTML rules?
Both. The first pass uses the lenient HTML5 parser that real browsers ship with. The second pass uses XHTML rules to catch issues HTML5 would auto-correct, like unclosed void elements or mismatched casing. Errors from either pass are merged into the result list.
Is the HTML stored or logged?
No. The markup is parsed in your browser and discarded when you leave the page. ShotMark does not log inputs, capture analytics on the textarea contents, or sync anything to a server. Pages with auth-protected URLs, internal copy, or PII are safe to paste.
Can the validator render the page?
No, this tool only validates. To render markup safely in a sandboxed preview, use the HTML Viewer instead, which runs the input inside an isolated iframe.
What does “premature end of data” mean?
The parser reached the end of the input while still expecting a closing tag. The fix is almost always a missing </div>, </section>, or </span> earlier in the document. Scroll back from the bottom and look for the most recently opened block element without a closer.
Will it flag deprecated HTML 4 tags?
Not as errors. Tags like <center>, <font>, and <marquee> parse without complaint because the HTML5 parser still tolerates them for legacy reasons. For a deprecation report, use a linter like HTMLHint or the W3C Nu Html Checker with strict mode.
Related tools
- CSS Validator. Check CSS syntax against W3C parsing rules.
- HTML Viewer. Render HTML safely inside a sandboxed iframe.
- HTML Prettify. Reformat HTML with consistent indentation and line breaks.
- Credit Card Validator. Verify card numbers with the Luhn algorithm.
Related tools
ShotMark captures what you do here, in one click.
The traces, payloads, and tests you run by hand? ShotMark grabs the whole bug and hands it to your AI agent.