npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

robots-txt-kit

v0.1.0

Published

Parse and evaluate robots.txt rules with structured diagnostics.

Downloads

134

Readme

robots-txt-kit

License: MPL-2.0 CI

Parse and evaluate robots.txt rules with structured diagnostics.

robots-txt-kit is a clean-room TypeScript draft for tools that need to inspect crawl policy without fetching files, caching domains, or depending on Node-only APIs.

Links: Demo · GitHub

Install

npm install robots-txt-kit

Quick Start

import { checkRobotsTxt, parseRobotsTxt } from "robots-txt-kit";

const robots = `
User-agent: *
Disallow: /private
Allow: /private/public
Sitemap: https://example.com/sitemap.xml
`;

const parsed = parseRobotsTxt(robots);
const decision = checkRobotsTxt(robots, "https://example.com/private/public/page", {
  userAgent: "ExampleBot"
});

console.log(parsed.document.sitemaps);
console.log(decision.allowed); // true
console.log(decision.rule?.line); // 4

API

parseRobotsTxt(input)

Parses a string into groups, rules, sitemaps and diagnostics. Expected problems return stable diagnostics instead of throwing.

const result = parseRobotsTxt("User-agent: *\nDisallow: /tmp");

if (result.ok) {
  console.log(result.document.groups[0]?.rules);
}

checkRobotsTxt(input, urlOrPath, options?)

Parses and evaluates in one call. urlOrPath may be an absolute URL or a path beginning with /.

checkRobotsTxt("User-agent: *\nDisallow: /*.json$", "/feed.json");

matchRobotsTxt(document, urlOrPath, options?)

Evaluates a pre-parsed document.

const parsed = parseRobotsTxt(robots);
const decision = matchRobotsTxt(parsed.document, "/admin", {
  userAgent: "Googlebot"
});

listRobotsTxtSitemaps(input)

Small helper for extracting valid Sitemap: directives.

Options

| Option | Default | Description | | --- | --- | --- | | userAgent | "*" | User agent used to select the best group. Matching is lowercase and substring-based. | | defaultAllowed | true | Decision when no matching group or rule exists. |

Diagnostics

Diagnostics are objects with stable code values and optional line numbers:

  • invalid-input
  • invalid-options
  • empty-input
  • missing-colon
  • empty-directive
  • empty-user-agent
  • rule-before-user-agent
  • unsupported-directive
  • invalid-crawl-delay
  • invalid-url

Scope

The MVP supports:

  • User-agent, Allow, Disallow, Sitemap and Crawl-delay;
  • grouped adjacent User-agent lines;
  • merging rules from multiple groups with the same best matching user-agent;
  • wildcard * and end-anchor $ path matching;
  • percent-encoding normalization for path inputs such as /café;
  • most-specific rule selection, with Allow winning specificity ties;
  • browser, worker and build-tool usage with no runtime dependencies.

It intentionally does not fetch remote robots.txt files, cache domains, implement every crawler-specific extension, ship a public suffix list, or replace crawler-specific validators. Treat it as a portable inspector for local policy checks.

Package quality

  • TypeScript types are generated from the source.
  • ESM-only package with no runtime dependencies.
  • Defensive API: invalid inputs and invalid runtime options return diagnostics instead of throwing.
  • CI runs npm ci, typecheck, build, and test.
  • Tested on Node.js 20 and 22 with GitHub Actions.

License

MPL-2.0