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 🙏

© 2025 – Pkg Stats / Ryan Hefner

parse-llms-txt

v0.0.9

Published

A JavaScript parser for [llms.txt](https://llmstxt.org) files that converts the structured markdown format into JSON.

Readme

parse-llms-txt

A JavaScript parser for llms.txt files that converts the structured markdown format into JSON.

What is llms.txt?

The llms.txt specification provides a standardized way for websites to offer LLM-friendly content. It's a markdown file located at /llms.txt that contains:

  • Project title (H1 header - required)
  • Description (blockquote - optional)
  • Details (content before first H2 - optional)
  • Sections (H2 headers with file lists - optional)

Learn more at llmstxt.org.

Installation

npm install parse-llms-txt

Usage

As a Module

import { parseLlmsTxt } from "parse-llms-txt";

// Parse from string
const markdown = `
# My Project

> A brief description of my project

Some additional details here.

## Documentation

- [API Reference](https://example.com/api.md): Complete API documentation
- [Quick Start](https://example.com/start.md): Getting started guide

## Examples

- [Basic Example](https://example.com/basic.md)
`;

const parsed = parseLlmsTxt(markdown);
console.log(parsed);

From URL

import { parseLlmsTxt } from "parse-llms-txt";

const response = await fetch("https://docs.parallel.ai/llms.txt");
const content = await response.text();
const parsed = parseLlmsTxt(content);

console.log(`Project: ${parsed.title}`);
console.log(`Sections: ${parsed.sections.length}`);

Command Line Interface

# Parse from file
npx parse-llms-txt llms.txt

# Parse from URL
npx parse-llms-txt https://docs.parallel.ai/llms.txt

# With Bun
bun run parse-llms-txt https://docs.parallel.ai/llms.txt

Output Format

The parser returns a JSON object with this structure:

{
  title: string,           // Project name from H1 (required)
  description?: string,    // Description from blockquote (optional)
  details?: string,        // Content before first H2 (optional)
  sections: [              // H2 sections with file lists
    {
      name: string,        // Section name
      files: [             // File entries
        {
          name: string,    // Link text
          url: string,     // Link URL
          notes?: string   // Optional notes after ":"
        }
      ]
    }
  ]
}

Example Output

Given this llms.txt:

# FastHTML

> FastHTML is a python library for creating server-rendered hypermedia applications.

Important notes about compatibility and usage.

## Documentation

- [Quick Start](https://fastht.ml/docs/quickstart.html.md): A brief overview
- [HTMX Reference](https://github.com/bigskysoftware/htmx/blob/master/www/content/reference.md): HTMX documentation

## Optional

- [Full Documentation](https://fastht.ml/docs/full.md): Complete documentation

The parser produces:

{
  "title": "FastHTML",
  "description": "FastHTML is a python library for creating server-rendered hypermedia applications.",
  "details": "Important notes about compatibility and usage.",
  "sections": [
    {
      "name": "Documentation",
      "files": [
        {
          "name": "Quick Start",
          "url": "https://fastht.ml/docs/quickstart.html.md",
          "notes": "A brief overview"
        },
        {
          "name": "HTMX Reference",
          "url": "https://github.com/bigskysoftware/htmx/blob/master/www/content/reference.md",
          "notes": "HTMX documentation"
        }
      ]
    },
    {
      "name": "Optional",
      "files": [
        {
          "name": "Full Documentation",
          "url": "https://fastht.ml/docs/full.md",
          "notes": "Complete documentation"
        }
      ]
    }
  ]
}

API Reference

parseLlmsTxt(markdown: string): LlmsTxtFile

Parses an llms.txt markdown string into a structured JSON object.

Parameters:

  • markdown (string): Raw markdown content of the llms.txt file

Returns: LlmsTxtFile object with parsed components

parseListLine(line: string): FileEntry | null

Parses a single markdown list line to extract file information.

Parameters:

  • line (string): Markdown list line starting with "- "

Returns: FileEntry object or null if parsing fails

Type Definitions

/**
 * @typedef {Object} FileEntry
 * @property {string} name - Display name of the file/link
 * @property {string} url - URL to the resource
 * @property {string} [notes] - Optional notes describing the file
 */

/**
 * @typedef {Object} Section
 * @property {string} name - Section name from H2 header
 * @property {FileEntry[]} files - Array of file entries
 */

/**
 * @typedef {Object} LlmsTxtFile
 * @property {string} title - Project title from H1 header
 * @property {string} [description] - Optional description from blockquote
 * @property {string} [details] - Optional details before first H2
 * @property {Section[]} sections - Array of sections
 */

Runtime Support

This package works with:

  • Node.js (18+ recommended)
  • Bun (latest)
  • Browsers (ES2020+)

Examples in the Wild

Try parsing these real llms.txt files:

# Parallel AI Platform
npx parse-llms-txt https://docs.parallel.ai/llms.txt

# FastHTML Documentation
npx parse-llms-txt https://www.fastht.ml/docs/llms.txt

# Answer.AI projects
npx parse-llms-txt https://fastcore.fast.ai/llms.txt

Contributing

Found a bug or want to contribute? Visit our GitHub repository.

License

MIT

Related