Skip to main content

llms-generator

PyPI CI Docs Python Versions License

Crawl any website and generate llms.txt. A Markdown file at your domain root that tells AI systems which pages to read.

Homepage: https://abdulaouwal.com/project/llms-generator/ Documentation: https://llms-generator.readthedocs.io/


Why llms.txt?

ChatGPT, Claude, and Gemini have small context windows. They cannot read your entire website. llms.txt gives them your essential pages in one request.

The llms.txt specification was proposed by Jeremy Howard in September 2024. It works alongside robots.txt and sitemap.xml. Each serves a different purpose.


Installation

pip install llms-generator

For JavaScript-heavy sites:

pip install llms-generator[js]
playwright install chromium

Requires: Python 3.10+. Core dependencies are requests and beautifulsoup4; Playwright is optional (extra js).


Usage

llms-gen https://example.com

This creates llms.txt in your current folder. Add --full to also generate the full content version.

Options

Flag Default Description
URL required Target website URL
--depth 2 Maximum crawl depth
--output llms.txt Output file path
--full false Also generate llms-full.txt
--no-js false Skip Playwright JS fallback
--delay 1.0 Base seconds between requests (adapts to response time)
--timeout 30 Per-request timeout in seconds
--max-pages 0 Stop after this many pages (0 = unlimited)
--prefer-markdown false Link to each page's markdown alternate when advertised
--optional-paths none Extra path names to move into ## Optional
--check false Validate the output against the spec
-v, --verbose false Enable debug logging
--version Show the version and exit

Examples

llms-gen https://example.com
llms-gen https://example.com --depth 3 --output site-llms.txt
llms-gen https://example.com --full
llms-gen https://example.com --no-js --delay 0.5
llms-gen https://example.com --max-pages 100 --timeout 15 --check
llms-gen https://example.com --prefer-markdown --optional-paths changelog,careers

How it works

Robot checks

Every page passes three checks:

  1. robots.txt - skips disallowed paths
  2. X-Robots-Tag - respects noindex and nofollow from HTTP headers
  3. <meta name="robots"> - respects page-level directives

Pages marked noindex are excluded. Pages marked nofollow are analyzed but their links are not crawled.

Crawl steps

  1. Parse robots.txt. Handles missing or restricted files, honors crawl-delay, and matches a fixed llms-generator user-agent token.
  2. BFS from the start URL up to --depth levels. Tracking parameters (utm_*, fbclid, gclid, ref, …) are stripped so they do not cause duplicate crawls.
  3. For each page:
    • Fetch with requests, retrying transient 429/5xx/timeouts with Retry-After backoff
    • Skip 4xx/5xx responses, non-HTML content, and off-domain redirects
    • Fall back to Playwright if content is empty (JS-rendered sites)
    • Extract title, h1, meta description, og:site_name, and main content text
  4. Group pages by top-level directory path
  5. Write llms.txt

Section grouping

/docs/getting-started   -> ## Docs
/blog/hello-world       -> ## Blog
/api/v1/users           -> ## Api

Pages without a directory path use their <h1> as the section name. Secondary pages (privacy, terms, cookies, legal, tags, authors, archives, …) are placed in a trailing ## Optional section, as recommended by the spec. Use --optional-paths to add your own.


Output

The generated llms.txt follows the llmstxt.org specification:

# Example Site
> A great example site with documentation and blog content.

## Docs
- [Getting Started](https://example.com/docs/getting-started): How to get started.
- [API Reference](https://example.com/docs/api): Complete API documentation.

## Blog
- [Hello World](https://example.com/blog/hello): Our first blog post.

With --full, the tool also writes llms-full.txt with every page's full text under section headings.


Contributing

  1. Fork the repo and clone it
  2. Create a branch: git checkout -b my-change
  3. Install for development: pip install -e .
  4. Run tests: python -m pytest tests/
  5. Push and open a pull request

Keep PRs focused. One change per PR. Write a clear description of what you changed and why.


Changelog

See CHANGELOG.md for the full release history.

Metadata

Release files for llms-generator 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for llms-generator 0.3.0
File Size Uploaded
llms_generator-0.3.0.tar.gz 18.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for llms-generator 0.3.0
File Interpreter ABI Platform
llms_generator-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 34.1 kB

Release files / llms_generator-0.3.0.tar.gz

Download URL llms_generator-0.3.0.tar.gz
Size 18.5 kB
Tags Source
SHA-256 checksum
How to use checksums
a7cf8f6bf730d16f9db45647246ba421ff81692728d070bae7f55208fe8dc5e2
BLAKE2b-256 checksum
How to use checksums
7a5b1229feeea247f5244e61fe4070b3d7f7bd9bf6d47890c59adfcadecafcba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 18, 2026.

Transparency log

Release files / llms_generator-0.3.0-py3-none-any.whl

Download URL llms_generator-0.3.0-py3-none-any.whl
Size 15.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
40b09ab31014e6bca216811bd798f89bf9d078b0cf5154483ae4332359539a39
BLAKE2b-256 checksum
How to use checksums
db6cc72aadc6419a414b478ac6171e98945a5b047ae58c4faa31f79b547c13ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 18, 2026.

Transparency log

Release history Release notifications | RSS feed

0.3.2

2 release files

0.3.1

2 release files

This release

0.3.0 This release

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.11

2 release files

0.1.9

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page