Skip to content

Pa11y Accessibility Tool — Complete Guide

DodaTech Updated 2026-06-28 3 min read

In this tutorial, you will learn about Pa11y Accessibility Tool. We cover key concepts, practical examples, and best practices to help you master this topic.

Pa11y is an automated Accessibility Testing tool that runs from the command line or Node.js API, supporting multiple HTML standards, customizable rules, JSON and CSV output, and a dashboard for continuous monitoring.

What You'll Learn

You will install and configure Pa11y, run scans against URLs and HTML files, configure rules and standards, output results in multiple formats, and set up Pa11y Dashboard for monitoring.

Why It Matters

Pa11y is lightweight, scriptable, and ideal for CI/CD integration. Its dashboard provides historical trend data so teams can track accessibility over time and catch regressions early.

Real-World Use

A news website runs Pa11y daily against their top 50 pages. The dashboard shows a spike in errors when a new ad script injects unlabeled iframes. The team is notified, and the ad vendor fixes the issue within 24 hours.

Pa11y Workflow

flowchart TD
  A[Pa11y Scan] --> B[Configure Options]
  B --> C[Run Scan]
  C --> D[Parse Results]
  D --> E{Output Type}
  E -->|JSON| F[CI Integration]
  E -->|CSV| G[Spreadsheet]
  E -->|HTML| H[Dashboard]
  F --> I[Fail Build]
  G --> J[Share Report]
  H --> K[Monitor Trends]

Installation and Usage

Install Pa11y globally or as a project dependency. The CLI accepts a URL and returns a JSON array of issues.

# Install globally
npm install -g pa11y

# Basic scan
pa11y https://example.com

# Scan with WCAG AA standard
pa11y https://example.com --standard WCAG2AA

# Save results as HTML report
pa11y https://example.com --reporter html > report.html
// Pa11y programmatic API
const pa11y = require('pa11y');

async function runAccessibilityCheck(url) {
  try {
    const results = await pa11y(url, {
      standard: 'WCAG2AA',
      wait: 5000,
      timeout: 30000,
      ignore: ['notice']
    });

    results.issues.forEach(issue => {
      console.log(`${issue.type}: ${issue.message}`);
      console.log(`  Selector: ${issue.selector}`);
      console.log(`  WCAG: ${issue.wcag}`);
    });

    const errors = results.issues.filter(i => i.type === 'error');
    console.log(`Total errors: ${errors.length}`);
    return errors.length;
  } catch (error) {
    console.error('Pa11y error:', error);
    return -1;
  }
}
<!-- Pa11y would report these issues -->
<html>
<head>
  <title>Untitled page</title>
</head>
<body>
  <img src="photo.jpg">
  <button onclick="submit()">Submit</button>
</body>
</html>

Common Mistakes

  • Not specifying the correct WCAG standard
  • Ignoring warnings and focusing only on errors
  • Using default wait time for slow single-page apps
  • Not configuring Pa11y to ignore known, documented issues
  • Running scans without a headless browser configured
  • Forgetting to check the HTML reporter for visual context
  • Not setting up thresholds in CI to avoid alert fatigue

Practice and Challenge

Practice 1: Install Pa11y and scan a public URL. Practice 2: Run Pa11y with WCAG2AAA standard and compare results. Practice 3: Use the HTML reporter and open the report in a browser. Practice 4: Write a Node.js script that scans three URLs and sums total issues. Practice 5: Configure Pa11y to ignore notices and only report errors and warnings.

Challenge: Build a GitHub Action that runs Pa11y on every PR against the deployment URL, fails if there are more than 5 errors, and posts the error count as a PR comment.

FAQ

What standards does Pa11y support?

Pa11y supports Section508, WCAG2A, WCAG2AA, and WCAG2AAA standards.

Does Pa11y require a browser?

Yes, Pa11y uses a headless browser (default Puppeteer) to render pages before scanning.

How is Pa11y different from axe-core?

Pa11y uses HTML_CodeSniffer as its default engine, not axe-core. Both are valid but produce different results.

Can Pa11y test single-page applications?

Yes, but you may need to increase the wait time for JavaScript-rendered content.

Is Pa11y Dashboard free?

Pa11y Dashboard is open source and free to self-host.

Can I add custom rules to Pa11y?

Yes, Pa11y supports custom rules through its programmatic API configuration.

Mini Project

Install and set up Pa11y Dashboard on a local server. Configure it to monitor three URLs with hourly scans. Let it run for 24 hours and review the trend data. Document any patterns you observe.

What's Next

HTML CodeSniffer covers using HTML_CodeSniffer for bookmarklet-based accessibility checking.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro