@chrisballam/llms-txt-generator
v1.0.1
Published
Generate llms.txt and llms-full.txt files for your website so AI answer engines (ChatGPT, Claude, Perplexity, Google AI Overviews) can discover and cite your content.
Maintainers
Readme
llms-txt-generator
Created by Chris Ballam.
Generate llms.txt and llms-full.txt for any website so AI answer engines — ChatGPT, Claude, Perplexity, Google AI Overviews, and others — can discover, understand, and cite your content.
- Zero runtime dependencies. Uses only the Node.js standard library (built-in
fetch,node:util,node:test). Nothing to audit, nothing tonpm audit. - Sitemap-first, crawl-fallback. Reads
sitemap.xml(including sitemap indexes); if none exists, it does a bounded same-origin crawl. - Both files. Produces the compact
llms.txtindex and the expandedllms-full.txtwith full page text. - Usable as a CLI or a library.
What is llms.txt?
llms.txt is a proposed convention — a single Markdown file at the root of your domain (/llms.txt) that gives large language models a clean, curated map of your site: a title, a short summary, and grouped links with descriptions. llms-full.txt goes further and inlines the actual page text so a model can answer from your content without crawling every page.
It is to AI answer engines roughly what sitemap.xml and robots.txt are to search crawlers.
Note:
llms.txtis an emerging convention, not a guaranteed ranking signal. Treat it as one clean, low-cost input to your GEO/AEO strategy — not a silver bullet. Google Search does not consume it today.
Requirements
Node.js >= 18.17 (for a stable built-in fetch and node:test).
Install
Run without installing:
npx @chrisballam/llms-txt-generator https://example.comOr install globally (the command is llms-txt):
npm install -g @chrisballam/llms-txt-generator
llms-txt https://example.comOr add to a project:
npm install @chrisballam/llms-txt-generatorCLI usage
# Simplest case — writes ./llms.txt
llms-txt https://example.com
# Also write llms-full.txt, into ./public
llms-txt https://example.com --full --out public
# Skip noisy URLs
llms-txt https://example.com --exclude "*/tag/*" --exclude "*/author/*" --exclude "*?*"
# Print to stdout instead of writing files (pipe it somewhere)
llms-txt https://example.com --stdout > llms.txt
# Drive everything from a config file
llms-txt --config llms-txt.config.jsonOptions
| Flag | Description | Default |
|------|-------------|---------|
| -c, --config <path> | Load options from a JSON file. | — |
| -o, --out <dir> | Output directory. | . |
| -m, --max <n> | Max pages to include. | 100 |
| -f, --full | Also write llms-full.txt. | off |
| --sitemap <url> | Explicit sitemap URL. | <site>/sitemap.xml |
| --title <str> | Title for the generated files. | site hostname |
| --summary <str> | One-line summary (blockquote). | first page description |
| --include <glob> | Only keep matching URLs (repeatable). | — |
| --exclude <glob> | Drop matching URLs (repeatable). | — |
| --concurrency <n> | Parallel fetches. | 5 |
| --timeout <ms> | Per-request timeout. | 15000 |
| --stdout | Print llms.txt to stdout. | off |
| -q, --quiet | Suppress progress logging. | off |
| -h, --help | Show help. | — |
| -v, --version | Show version. | — |
Globs support * and ?; a pattern with no wildcard is treated as a substring match.
Config file
CLI flags override config-file values. See llms-txt.config.example.json:
{
"site": "https://example.com",
"title": "Example Company",
"summary": "Example Company builds widgets that make your workflow faster.",
"full": true,
"outDir": "public",
"maxPages": 200,
"exclude": ["*/tag/*", "*/author/*", "*?*"]
}Programmatic API
generate() returns the file contents; it does not write to disk, so you can post-process or write them yourself.
import { generate } from '@chrisballam/llms-txt-generator';
const { llmsTxt, llmsFullTxt, pages, failures } = await generate({
site: 'https://example.com',
full: true,
exclude: ['*/tag/*'],
});
console.log(llmsTxt); // the compact index
console.log(pages.length); // pages successfully processed
console.log(failures); // [{ url, status, error }]You can inject a custom fetcher (handy for testing or for adding auth headers):
await generate({ site: 'https://example.com' }, {
fetcher: async (url) => ({ ok: true, status: 200, contentType: 'text/html', body: '<title>Hi</title>' }),
log: (msg) => console.error(msg),
});Lower-level building blocks are exported too: fetchUrl, discoverFromSitemap, crawlSite, extractPage, htmlToText, renderLlmsTxt, renderLlmsFullTxt.
Output shape
llms.txt:
# example.com
> Example Company builds widgets that make your workflow faster.
## Pages
- [Home](https://example.com/): The home page.
## Blog
- [Hello world](https://example.com/blog/hello): Our first post.llms-full.txt uses the same header, then appends each page's full extracted text under a ## Title / Source: block.
How to deploy it
- Run the generator and write
llms.txt(and optionallyllms-full.txt) to your web root. - Serve them at
https://yourdomain.com/llms.txtandhttps://yourdomain.com/llms-full.txtastext/plainortext/markdown. - Regenerate on each deploy (a CI step or cron) so the files stay in sync with your content.
Development
git clone https://github.com/chrisballam/llms-txt-generator.git
cd llms-txt-generator
node --test # run the test suite (no install needed)There are no dependencies to install — tests run straight from a clean checkout.
Contributing
Issues and PRs welcome. Please keep the zero-dependency constraint: standard library only.
License
MIT © Chris Ballam
