HTML Getting Started

Compare HTML from Base and Contrast through reconstructed results, Git Diff, URL loading, troubleshooting, and sharing privacy.

Compare HTML compares a parse5 virtual-node tree rather than treating a page only as lines of text. This guide follows a server-rendered account page from Base and Contrast through result review, original-text diffing, and safe sharing.

Start with Base and Contrast

The editors have a direction:

EditorPut hereTypical examples
BaseThe original or reference markupDeployed SSR output, an approved email template, a saved component fixture
ContrastThe markup you want to checkNew SSR output, a revised email, the latest component render

A node or attribute found only in Contrast is Added. One found only in Base is Deleted. Swapping the inputs exchanges those categories and reverses the before-and-after values of a change.

A complete example

Suppose a template revision changes an account panel. Paste this complete document into Base:

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Account</title>
  </head>
  <body>
    <!-- deployed account panel -->
    <main id="account" class="panel">
      <h1>Welcome, Ada</h1>
      <ul class="sessions">
        <li data-region="us-east">Current session</li>
        <li data-region="eu-west">Previous session</li>
      </ul>
      <a class="button" href="/settings">Manage account</a>
    </main>
  </body>
</html>

Paste the proposed output into Contrast:

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Account</title>
  </head>
  <body>
    <!-- proposed account panel -->
    <main class="panel wide" id="account">
      <h1>Welcome, Ada</h1>
      <ul class="sessions">
        <li data-region="us-east">Current  session</li>
        <li data-region="eu-west">Previous session</li>
        <li data-region="ap-south">New session</li>
      </ul>
      <a href="/account/settings" class="button">Manage account</a>
    </main>
  </body>
</html>

The main class, link destination, comment, first session text, and added session are differences. The doubled space in Current session matters because it is inside non-empty text. Reordering the id and class attributes does not itself create a difference.

Enter the HTML

Open Compare HTML and use either editor to:

  • paste a complete document or an HTML fragment;
  • drag and drop an HTML file, or use the file-loading action;
  • import HTML from an HTTP/HTTPS URL. A GitHub Gist page URL is resolved to its raw file content.

For URL imports, the source must be accessible to your browser, return HTML or plain text, and allow the browser request through CORS. Downloading a response does not prove that its markup follows the HTML standard.

Parsing and comparison run locally in your browser. Importing from a URL contacts the source you specify; read the privacy note below before using Share or placing data in a URL.

Understand the fixed comparison rules

There is no HTML settings panel or selectable child-matching method. At every level, significant children are aligned with a fixed Longest Common Subsequence (LCS) algorithm based on node type and, for elements, tag name. Matched nodes are then compared recursively. Unmatched nodes become additions or deletions.

Attribute names and values are compared independently of attribute order. Text is compared as text, including numeric-looking strings. Comments and doctypes are represented and compared. Whitespace-only text nodes between elements are ignored, but whitespace inside meaningful non-empty text is not generally normalized. See HTML Comparison Rules for reorder examples and parser limits.

Run the comparison

Select Compare. Both inputs are parsed with parse5, then their virtual-node trees are compared recursively. The result page opens at /tools/compare-html/result in Data Compare view.

Result categories have these meanings:

  • Added (green): a node or attribute exists only on the Contrast side.
  • Deleted (red): a node or attribute exists only on the Base side.
  • Value Changed (yellow): corresponding text, comments, doctypes, tags, or attribute values differ.

Same means the parsed trees are equal under these fixed rules. It does not mean the original source is byte-for-byte identical or standards-valid.

Read the reconstructed result

The Data Compare sidebar groups differences by category and shows element paths. Select an entry to reveal its location in the aligned editors, or use the category controls to focus the review.

Data Compare renders HTML reconstructed from the parsed virtual nodes. It is not an exact source mapping: indentation, line layout, attribute presentation, and other source spelling can differ from what you entered. parse5 can also supply implied document structure when it parses a full page.

Use the two views for different questions:

  • Data Compare asks what changed in the parsed HTML tree.
  • Git Diff asks what changed in the original text entered into each editor. It can show formatting, attribute layout, and other source edits even when Data Compare reports Same.

Neither view executes the compared page or checks its visual rendering in a browser.

Sharing and sensitive data

Entering or pasting HTML for comparison does not upload it. Parsing and comparison run locally in your browser. Using Share uploads the compared content to the share server and creates a link to /tools/compare-html/result with a share_id; anyone with that link can load the stored snapshot until it expires.

Data placed in URL query parameters is sent with page requests and may be recorded in hosting logs, so do not place sensitive data in URLs. This applies to Base64-encoded HTML as well as remote source addresses. Importing from a URL also sends a request to the source you specify.

Troubleshooting

Malformed markup still produces a result

validateHTML is not a standards validator. parse5 applies HTML error-recovery rules, so mismatched or missing tags may be repaired into a tree instead of rejected. Inspect the reconstructed structure and use a dedicated HTML validator when conformance matters.

Reordered content produces unexpected changes

Fixed LCS remains order-sensitive. Reordering siblings with the same tag can align them by position within the matched sequence and expose text or attribute edits; mixed node types can instead produce additions and deletions. There is no move operation or unordered mode. Use Git Diff to review the exact source rearrangement.

A formatting-only edit appears or disappears unexpectedly

Whitespace-only nodes between elements are ignored, but changes within non-empty text remain significant. Attribute order and layout around a tag do not matter to Data Compare. Switch to Git Diff when the source formatting itself is under review.

A URL import fails

Confirm that both Base and Contrast parameters or editor imports use accessible HTTP/HTTPS URLs. Check the response content type, authentication requirements, and CORS policy. For a Gist, verify that the link identifies accessible content. If the response contains unexpected markup, inspect the downloaded source before comparing it.

Read HTML Comparison Rules for precise matching, whitespace, comment, doctype, and numeric-text behavior.

Browse the documentation

Find practical guides for comparison options, sharing, browser extensions, AI assistants, and language libraries.