Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including amphtml-validator with all npm packages installed. Try it out:

var amphtmlValidator = require("amphtml-validator")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

amphtml-validator v1.0.32

Official validator for AMP HTML (

amphtml-validator Node.js Package

This package is published and available at

The source code is available at

Command Line Tool

The amphtml-validator command line tool is documented here:

Node.js API

This API is new - feedback is especially welcome.

To install, use npm install amphtml-validator in your project directory, or add amphtml-validator as a dependency to your package.json.

You may save the following example into a file, e.g., demo.js.

'use strict';
var amphtmlValidator = require('amphtml-validator');

amphtmlValidator.getInstance().then(function (validator) {
  var result = validator.validateString('<html>Hello, world.</html>');
  (result.status === 'PASS' ? console.log : console.error)(result.status);
  for (var ii = 0; ii < result.errors.length; ii++) {
    var error = result.errors[ii];
    var msg =
      'line ' + error.line + ', col ' + error.col + ': ' + error.message;
    if (error.specUrl !== null) {
      msg += ' (see ' + error.specUrl + ')';
    (error.severity === 'ERROR' ? console.error : console.warn)(msg);

Now try running it:

$ node demo.js
line 1, col 0: The mandatory attribute '⚡' is missing in tag 'html ⚡ for top-level html'. (see
line 1, col 0: The parent tag of tag 'html ⚡ for top-level html' is '$root', but it can only be '!doctype'. (see

As expected, this emits errors because the provided string in the example, <html>Hello, world.</html> is not a valid AMP HTML document.

Release Notes


  • Removal of AMP Actions format as it is deprecated.


  • Fix Node API on Node > 12


  • Remove engine section from pacakge.json to allow any version of nodejs.


  • Reintroduce node v8 support. Supports node v8, v10, v12 and v14.


  • Reintroduce node v10 support and introduce node v14 support.


  • Removed references to amp.validator.categorizeError.


  • Introduce node v12 support and remove node v10 support.


  • Broken release, removed.


  • Introduce node v10 support and remove node 8 support.


  • The amphtml-validator binary now requires the Node.js binary to be called node. On systems where the Node.js binary is called nodejs, consider installing the nodejs-legacy Debian package or better yet, NVM.


  • --html_format=AMP4EMAIL added.


  • --html_format=AMP4ADS is no longer experimental.


  • Better npm post-install for virtual machines, running debian over windows with SMB shared folder.


  • Set correct process exit status for old versions of Node.js (v0.10.25).


  • Small tweaks to this file and package.json.


  • If the amphtml-validator command is already patched up for Windows, leave it alone instead of failing. Relevant if the package has been installed globally and now we're performing a local install on top of it.


  • npm install amphtml-validator (local install) should now work on Windows, for require('amphtml-validator').


  • Added support for installing on Windows. npm install -g amphtml-validator should now just work.


  • Added newInstance method, a simple API that's not async.


  • Added support for --user-agent option.


  • Added support for AMP4ADS (via --html_format command line flag) and argument for validateString function in the API.



RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free