Find broken links, missing images, etc in your HTML. Scurry around your site and find all those broken links.
npx @tessl/cli install tessl/npm-linkinator@6.1.0Linkinator is a comprehensive broken link checker and site crawler that provides both CLI and API functionality for validating links in HTML, markdown, and local files. It features concurrent scanning with configurable parallelism, recursive crawling capabilities, support for various link types (absolute, relative, redirects), regex-based URL filtering for inclusion/exclusion, automatic static server setup for local file scanning, and multiple output formats (JSON, CSV).
npm install linkinatorimport { check, LinkChecker, LinkState, DEFAULT_USER_AGENT } from "linkinator";For CommonJS:
const { check, LinkChecker, LinkState, DEFAULT_USER_AGENT } = require("linkinator");import { check, LinkState } from "linkinator";
// Simple link checking
const result = await check({ path: "https://example.com" });
console.log(`Passed: ${result.passed}`);
console.log(`Total links: ${result.links.length}`);
// Check local files with markdown support
const localResult = await check({
path: "./docs/",
recurse: true,
markdown: true,
});
// Filter broken links
const brokenLinks = localResult.links.filter(
(link) => link.state === LinkState.BROKEN
);Linkinator is built around several key components:
Core link checking functionality for validating URLs and local files. Provides both synchronous batch processing and event-driven real-time scanning.
function check(options: CheckOptions): Promise<CrawlResult>;
class LinkChecker extends EventEmitter {
check(options: CheckOptions): Promise<CrawlResult>;
on(event: 'link', listener: (result: LinkResult) => void): this;
on(event: 'pagestart', listener: (link: string) => void): this;
on(event: 'retry', listener: (details: RetryInfo) => void): this;
}Configuration system supporting both programmatic options and file-based configuration with CLI flag precedence.
function getConfig(flags: Flags): Promise<Flags>;
interface CheckOptions {
concurrency?: number;
port?: number;
path: string | string[];
recurse?: boolean;
timeout?: number;
markdown?: boolean;
linksToSkip?: string[] | ((link: string) => Promise<boolean>);
serverRoot?: string;
directoryListing?: boolean;
retry?: boolean;
retryErrors?: boolean;
retryErrorsCount?: number;
retryErrorsJitter?: number;
urlRewriteExpressions?: UrlRewriteExpression[];
userAgent?: string;
}Command-line tool providing direct access to linkinator functionality with comprehensive options for automation and CI/CD integration.
// CLI executable available at: linkinator
// Usage: linkinator LOCATIONS [--arguments]The CLI supports all CheckOptions through command-line flags and can output results in multiple formats (TEXT, JSON, CSV) with configurable verbosity levels.
interface CrawlResult {
passed: boolean;
links: LinkResult[];
}
interface LinkResult {
url: string;
status?: number;
state: LinkState;
parent?: string;
failureDetails?: Array<Error | GaxiosResponse>;
}
interface GaxiosResponse {
status: number;
statusText: string;
headers: Record<string, string>;
data: any;
config: any;
}
interface RetryInfo {
url: string;
secondsUntilRetry: number;
status: number;
}
enum LinkState {
OK = 'OK',
BROKEN = 'BROKEN',
SKIPPED = 'SKIPPED',
}
interface UrlRewriteExpression {
pattern: RegExp;
replacement: string;
}
/** Default user agent string used for HTTP requests */
const DEFAULT_USER_AGENT: string;