Ultra high quality Node.js library for managing:
sitemap.xml
fetching and parsing (supportshttp
,https
,file://
)llms.txt
generation, validation, and auto-correction (Markdown)- Parsing
llms.txt
to structured JSON (from file or remote URL)
Designed for robustness, strict validation, and enterprise integration — using only native Node.js modules.
- ✅ Robust
sitemap.xml
loading via HTTP(S) or local file system - ✅ Smart HTTP ↔ HTTPS fallback logic
- ✅ Auto-generates clean
llms.txt
from structured data - ✅ Validates and auto-corrects invalid Markdown input
- ✅ Parses
llms.txt
back to JSON format - ✅ Built-in title extraction and priority filtering from sitemap
- ✅ Zero dependencies (uses native Node.js modules only)
npm install llms-manager
import LLMSManager from "llms-manager";
(async () => {
try {
// 1. Create instance with sitemap URL
const manager = new LLMSManager({
sitemapUrl: "https://example.com/sitemap-pages.xml",
});
// 2. Load and parse the sitemap
await manager.loadSitemap();
console.log("Sitemap URLs:", manager.getSitemapEntries());
// 3. Set title and description for llms.txt
manager.setMetadata("My Site", "The best site ever");
// 4. Automatically generate core content from sitemap (threshold 0.4)
const coreContent = manager.autoGenerateCoreContent(0.4);
manager.addCoreContent(coreContent);
// 5. Add optional content manually
manager.addOptionalContent([
{ title: "Extra Link", url: "https://example.com/extra" },
]);
// 6. Generate llms.txt markdown (including validation & correction)
const llmsText = manager.generateLLMSTxt();
console.log("Generated llms.txt content:\n", llmsText);
// 7. Save file
await manager.saveToFile("./llms.txt");
console.log("llms.txt saved successfully.");
} catch (e) {
console.error("Error:", e);
}
})();
new LLMSManager({ sitemapUrl: string });
sitemapUrl
: Required. Must begin withhttp://
,https://
, orfile://
.
Fetch and parse the sitemap to internal entries.
Returns all parsed entries from the sitemap.
Set the title and description block for the generated llms.txt
.
Add core content entries.
Add optional content entries.
Returns the final llms.txt
markdown content as a string.
Saves the generated llms.txt
to a file.
Filters sitemap entries by priority
and auto-generates a title from the URL.
Parses llms.txt
markdown into structured JSON:
{
title: string;
description: string;
coreContent: Array<{ title: string, url: string }>;
optionalContent: Array<{ title: string, url: string }>;
}
Loads and parses a local llms.txt
file.
Loads and parses a remote llms.txt
file via HTTP/HTTPS.
# My Project
> A curated list of intelligent content.
## Core Content
- [Home](https://example.com/)
- [Blog](https://example.com/blog)
## Optional
- [About](https://example.com/about)
Use autoGenerateCoreContent()
after loading the sitemap to quickly fill out relevant content based on priority
.
- Node.js v18+ (uses
fs/promises
andURL
API) - No external dependencies
https
,http
fs/promises
,fs
url
Pull requests welcome! Please ensure your code is:
- Fully documented
- Tested
- Dependency-free
MIT — © 2025 Marius Heinrich