WebTools

307 Useful Tools & Utilities to make life easier.

AMP Validator

Validate your Accelerated Mobile Pages (AMP) for errors.

Why use AMP?

Speed

Instant Loading: AMP pages are optimized for speed and pre-cached by Google.

Visibility

Mobile SEO: Google prioritizes valid AMP pages in the mobile search results carousel.

Experience

UX: Provides a smooth, distraction-free reading experience for mobile users.

Compliance

Strict Standards: Even a single missing mandatory tag can invalidate the entire AMP status.

Decoding the AMP Validator: A Technical Overview

Accelerated Mobile Pages (AMP) are designed to provide lightning-fast loading speeds on mobile devices by enforcing a strict set of structural guidelines. The AMP Validator tool allows developers to input a URL and immediately verify if the target webpage adheres to the fundamental rules of the AMP framework. Instead of manually inspecting the document object model (DOM), this tool fetches the raw HTML and programmatically analyzes it using pattern matching.

When you submit a URL, the tool uses a backend HTTP client (configured with a 15-second timeout and allowing up to a standard limit of redirects) to fetch the webpage's body. Once retrieved, the raw HTML is subjected to a series of specific string comparisons and Regular Expression (Regex) checks to evaluate compliance. If the website cannot be reached or times out, the system will output a connection error.

What Exactly Does the Validator Check?

The core of the tool relies on a six-point audit system. Here is a breakdown of the exact criteria the engine looks for in the HTML:

  • AMP HTML Tag: The tool scans the <html> element for the presence of the amp attribute or the lightning bolt emoji (). It uses a case-insensitive regex pattern (/<html.*?\s(amp|⚡)/i) to confirm this mandatory declaration.
  • AMP JS Library: A valid AMP page must load the core AMP runtime. The script simply checks if the exact string https://cdn.ampproject.org/v0.js exists anywhere in the source code.
  • AMP Boilerplate: AMP requires a specific CSS boilerplate to hide the content until the AMP JS library is fully loaded. The tool verifies this by checking for the substring amp-boilerplate.
  • Canonical Link: To prevent duplicate content issues, AMP pages must link back to themselves or their non-AMP counterparts. A regex scan (/<link.*?rel=["']canonical["'].*?>/i) ensures this tag is present.
  • Viewport Meta: Mobile responsiveness is critical. The validator ensures that a viewport meta tag exists via the pattern /<meta.*?name=["']viewport["'].*?>/i.
  • Script Restrictions: The AMP framework strictly restricts custom JavaScript. The tool runs a regex check (/<script(?!.*?src=["']https://cdn\.ampproject\.org/).*?>/i) to see if there are any <script> tags that do not originate from the official AMP CDN. If unauthorized scripts are found, this specific check results in a "warning" rather than a hard failure.

Understanding the Overall Status

After evaluating the six criteria, the tool calculates an aggregated score. The rules for the final grade are straightforward:

  • Valid: 0 failed checks. All mandatory requirements are met.
  • Warning: 1 or 2 failed checks. The page has issues that might prevent it from being indexed as a valid AMP page by search engines.
  • Invalid: 3 or more failed checks. The page is fundamentally missing the core structure of the AMP framework.

Concrete Worked Example

Let’s examine how the tool processes a hypothetical input URL: https://example.com/blog-post/amp.

Suppose the server returns the following simplified HTML snippet:

<!doctype html>
<html amp lang="en">
  <head>
    <meta charset="utf-8">
    <script async src="https://cdn.ampproject.org/v0.js"></script>
    <link rel="canonical" href="https://example.com/blog-post">
    <style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end)...</style>
    <script src="https://analytics.example.com/tracker.js"></script>
  </head>
  <body>
    <h1>Hello World</h1>
  </body>
</html>

Evaluation Process:

  1. AMP HTML Tag: Passes. The <html amp ...> tag matches the regex.
  2. AMP JS Library: Passes. The string https://cdn.ampproject.org/v0.js is found in the head.
  3. AMP Boilerplate: Passes. amp-boilerplate exists in the style tag.
  4. Canonical Link: Passes. The rel="canonical" tag is clearly present.
  5. Viewport Meta: Fails. The required <meta name="viewport" content="..."> tag is missing from the head.
  6. Script Restrictions: Warning. The tracker script (https://analytics.example.com/tracker.js) triggers the negative lookahead regex because it does not source from cdn.ampproject.org.

Final Result: The audit yields 1 failure (Viewport Meta) and 1 warning (Script Restrictions). Because the total number of absolute failures is exactly 1 (which is less than 3), the tool will assign an overall status of "Warning".

Frequently Asked Questions

Why does the tool report a "Failed to reach the website" error?
The validator uses a backend HTTP client with a strict 15-second timeout limit. If your server is experiencing high latency, blocks server-side bots, or takes longer than 15 seconds to respond, the connection is dropped, and this error is displayed.
Why did my page trigger a warning for Script Restrictions?
The AMP framework generally forbids third-party JavaScript to guarantee performance. The tool specifically scans for <script> tags. If it detects any script whose src attribute does not start with https://cdn.ampproject.org/, or if it finds inline JavaScript, it flags it as a warning.
Does the tool check for the lightning bolt (⚡) symbol instead of the "amp" attribute?
Yes. The regex logic (/<html.*?\s(amp|⚡)/i) accepts either the standard amp text attribute or the lightning bolt emoji within the opening <html> tag, exactly as permitted by the official AMP specification.
Does this tool render the page to check for visual issues?
No. The validator performs a static source-code analysis by fetching the raw HTML response and testing it against specific string and regex patterns. It does not execute JavaScript or render the DOM.

Contact

Missing something?

Feel free to request missing tools or give some feedback using our contact form.

Contact Us