Playground Sign in Start free

Convert an Entire Website to Markdown for LLMs

Download runnable code Sign in to prefill your key
Website to Markdown (llms-full.txt and JSONL) Download
1

Website to Markdown in one job

To convert an entire website to Markdown for an LLM, crawl it as one job with "format": "markdown": every page comes back as clean Markdown with its URL, title and links, and your code writes the files your pipeline reads. Our crawl of the ujeebu.com docs read 20 pages for 200 credits (10 credits a page) and produced one 388 KB llms-full.txt and 363 JSONL chunks.

One crawl job, every page as Markdown
No changelogs, translations or duplicates
llms-full.txt in one file
JSONL chunks for embeddings
A crawl bill you can trust

A free quote gives the most a crawl can cost before it starts, and max_credits is a hard cap: the job stops before a page that would pass it. Failed and blocked pages are not billed.

Not sure how big the site is? Find all pages on a website lists its URLs for free first. The use case Website to RAG knowledge base shows where these files go next.

2

Start the crawl, capped at the quote

One job reads the docs section. Every page is one Markdown call with the fit filter, which keeps the main content and drops menus, footers and cookie banners. The script asks for the free quote first and passes its credits_ceiling as max_credits: the job cannot cost more than the quote said.

CRAWL = {
    "urls": ["https://ujeebu.com/docs"],
    "scope": {
        "include": ["/docs/**"],
        "exclude": [
            "/docs/changelog/**", "/docs/*/changelog/**",              # release notes: noise for retrieval
            "/docs/fr/**", "/docs/de/**", "/docs/es/**", "/docs/ja/**",  # translated copies of the same pages
        ],
        "max_pages": 20,
    },
    "use_sitemap": True,
    "format": "markdown",
    "markdown": {"filter": "fit"},   # main content only: no menus, footers or cookie banners
}
quote = api("POST", "/crawl/quote", json=CRAWL)
job = api("POST", "/crawl", json={**CRAWL, "max_credits": quote["credits_ceiling"]})
Output
Quote: 23 sitemap URLs in scope, 10 credits a page, at most 200 credits
Started c_d8d4a9a2-5b47-4b12-99fd-5b6c9d991522
FieldWhy
includeOnly paths under /docs; /docs/** also matches /docs itself.
excludeChangelogs and translated copies. An excluded page is out whatever the include patterns say; * stays in one path segment, ** crosses segments.
use_sitemapAlso start from the sitemap's in-scope URLs, so pages with few links pointing to them are not missed.
markdown.filterfit keeps the main content. raw keeps the whole page; bm25 with markdown.query keeps the passages that match a query.
max_creditsThe hard cap, set to the quote's credits_ceiling. Each page counts once, so this cap reads every page the quote priced.
3

RAG hygiene: leave the noise out

A knowledge base is only as good as what goes in. Four rules keep a crawled site clean for retrieval:

  1. Exclude what adds no knowledge: changelogs, translated copies, print views. The exclude patterns above keep them out of the crawl, so they are never billed either.
  2. Keep the main content: the fit filter drops navigation, footers and banners that would repeat in every chunk.
  3. Skip duplicates: a record whose state is not done (for example error_class duplicate, the same document as another page) is skipped, and so is a page whose content hash was already written under another URL.
  4. Flag oversized pages: a page over 50,000 characters is listed for review. Long reference pages are fine to chunk, but they can crowd the context of an answer.
for page in batch["pages"]:     # finished pages only, in a stable order
    if page["state"] != "done":
        print(f"  skipped   {page['url']} ({page.get('error_class')})")   # duplicate, blocked, ...
        continue
    if page["sha256"] in written:
        print(f"  skipped   {page['url']} (same content as a page already written)")
        continue
    markdown = (page.get("markdown") or "").strip()
    if len(markdown) > OVERSIZED:
        oversized.append(page["url"])
        print(f"  oversized {page['url']} ({len(markdown):,} characters): review it")
    ...                          # then write the page to llms-full.txt and docs.jsonl (below)

On the ujeebu.com docs the run flagged two reference pages and found no duplicates:

Output (two lines of the run)
  oversized https://ujeebu.com/docs/apis/scrape/extract-rules (63,470 characters): review it
  oversized https://ujeebu.com/docs/apis/serp (74,546 characters): review it
4

Read the pages with the cursor

GET /crawl/{id}/pages returns finished pages only, in a stable order, so you can read while the job runs. Pass after (0 first, then the next_after of the previous answer), limit up to 50, and content=true to get each page's Markdown.

AnswerWhat to do
has_more: trueCall again now from next_after.
has_more: false, finished: falseEverything final so far is read: ask again a few seconds later from the same next_after.
has_more: false, finished: trueDone: every page has been read.
while True:
    batch = api("GET", f"/crawl/{state['job_id']}/pages",
                params={"after": state["after"], "limit": 10, "content": "true"})
    for page in batch["pages"]:
        ...                          # skip, flag, write (above)
    state["after"] = batch["next_after"]
    save_state(state)
    if batch["has_more"]:
        continue                     # more finished pages are ready now
    if batch["finished"]:
        break                        # the job is over and every page has been read
    time.sleep(5)                    # everything final so far is read: ask again in a moment
Response (trimmed)
{
  "job_id": "c_d8d4a9a2-5b47-4b12-99fd-5b6c9d991522",
  "status": "completed",
  "finished": true,
  "pages": [
    {
      "seq": 8,
      "url": "https://ujeebu.com/docs/apis/scrape/raw",
      "state": "done",
      "http_status": 200,
      "title": "Scrape Raw",
      "depth": 0,
      "discovered_from": "https://ujeebu.com/sitemap.xml",
      "credits": 10,
      "bytes": 10392,
      "links": ["https://ujeebu.com/", "https://ujeebu.com/scrape", "..."],
      "links_total": 102,
      "sha256": "7f98d26867fb425e1d82489b1397cdc5d59c078df09a7854aea34ce2b08772de",
      "markdown": "# Scrape Raw\n\nGet the raw HTML source code as received from the server without JavaScript execution. ..."
    }
  ],
  "next_after": 8,
  "has_more": true
}

A page over 2 MB comes as a signed content_url instead of inline Markdown; the script downloads it. The script keeps the job id, the cursor and the hashes it wrote in crawl-state.json: stop it at any time, and the next run picks up from there without starting a new job.

5

Write llms-full.txt and chunk by heading

Every page goes into llms-full.txt as it is, with its source URL, separated by ---: one file a model can read in one go.

llms-full.txt (excerpt)
---

Source: https://ujeebu.com/docs/apis/scrape/raw

# Scrape Raw

Get the raw HTML source code as received from the server without JavaScript execution. Faster and more lightweight than full rendering.

## Overview

The raw response type returns the source HTML (or file content if URL is not an HTML page) exactly as received from the URL without running JavaScript. This is useful when:
...

For a vector index, the same page is cut into chunks. Documentation is already organised by headings, so they make natural boundaries: the function below starts a new chunk at every heading, starts another at a blank line once a chunk reaches about 1,500 characters, and never cuts a code block or a code span in two. Each chunk keeps its heading trail, which helps both retrieval and citations.

def chunk(markdown, max_chars=MAX_CHARS):
    """Split Markdown into (section, text) chunks: a new chunk at every heading, and at a blank
    line once the chunk has max_chars. Code (fenced blocks and code spans) is never cut in two."""
    chunks, trail, lines, in_code = [], [], [], False

    def flush():
        text = "\n".join(lines).strip()
        if text:
            chunks.append((" > ".join(trail), text))
        lines.clear()

    for line in markdown.splitlines():
        heading = None if in_code else re.match(r"(#{1,4})\s+(.+)", line)
        if heading:
            flush()
            trail[len(heading.group(1)) - 1:] = [heading.group(2).strip()]
            continue
        if line.count("`") % 2:     # a code block or a code span opens or closes on this line
            in_code = not in_code
        if not in_code and not line.strip() and sum(len(x) + 1 for x in lines) >= max_chars:
            flush()
        lines.append(line)
    flush()
    return chunks

Each chunk becomes one JSON line. The id is the page URL plus the chunk number, so writing the same page again replaces its chunks instead of adding copies:

docs.jsonl (one line)
{"id": "https://ujeebu.com/docs/apis/scrape#35", "url": "https://ujeebu.com/docs/apis/scrape", "title": "Scrape API", "section": "Scrape API > Examples > Scroll behavior", "text": "The API's scroll script will by default scroll down to the end of page, but this behavior can be customized using parameter `scroll_to_selector` which will define the selector of the element to scroll to.\n\nParameter `scroll_wait` defines the time in milliseconds to wait between two scrolls (default = 50)", "page_sha256": "d60507f5be3312edc25c12d31bb47f93598027f667de6e0ceb628170fa5d1e4f"}
6

Run it

The complete script: quote, capped job, cursor, hygiene, llms-full.txt and docs.jsonl. Delete the three files it writes to crawl again from scratch.

#!/usr/bin/env python3
"""Convert an entire website (here, a docs site) to Markdown for LLMs and RAG, with the Ujeebu Crawl API.

One crawl job reads the docs as Markdown, main content only, capped at the free quote's ceiling.
This script reads the pages as they arrive, skips duplicates, flags oversized pages and writes:
  llms-full.txt   every page in one Markdown file, with its source URL
  docs.jsonl      the same pages cut into chunks at their headings, one JSON line each, for embeddings
Stop it at any time: the next run resumes from the saved cursor.

    pip install requests
    UJEEBU_API_KEY=your-key python3 website_to_markdown.py
"""
import json
import os
import re
import time

import requests

API_KEY = os.environ.get("UJEEBU_API_KEY", "YOUR_API_KEY")
API = "https://api.ujeebu.com"

CRAWL = {
    "urls": ["https://ujeebu.com/docs"],
    "scope": {
        "include": ["/docs/**"],
        "exclude": [
            "/docs/changelog/**", "/docs/*/changelog/**",              # release notes: noise for retrieval
            "/docs/fr/**", "/docs/de/**", "/docs/es/**", "/docs/ja/**",  # translated copies of the same pages
        ],
        "max_pages": 20,
    },
    "use_sitemap": True,
    "format": "markdown",
    "markdown": {"filter": "fit"},   # main content only: no menus, footers or cookie banners
}
STATE_FILE = "crawl-state.json"     # job id, cursor and hashes written, so a stopped run can resume
MAX_CHARS = 1500                    # target chunk size
OVERSIZED = 50_000                  # flag pages longer than this for review

http = requests.Session()
http.headers["ApiKey"] = API_KEY


def api(method, path, **kwargs):
    """Call the Crawl API. A GET is tried again after a network error: polling runs for minutes."""
    for attempt in range(1, 4):
        try:
            response = http.request(method, API + path, timeout=120, **kwargs)
            break
        except requests.ConnectionError:
            if method != "GET" or attempt == 3:
                raise
            time.sleep(5 * attempt)
    if response.status_code >= 400:
        raise SystemExit(f"{method} {path}: {response.status_code} {response.text}")
    return response.json()


def chunk(markdown, max_chars=MAX_CHARS):
    """Split Markdown into (section, text) chunks: a new chunk at every heading, and at a blank
    line once the chunk has max_chars. Code (fenced blocks and code spans) is never cut in two."""
    chunks, trail, lines, in_code = [], [], [], False

    def flush():
        text = "\n".join(lines).strip()
        if text:
            chunks.append((" > ".join(trail), text))
        lines.clear()

    for line in markdown.splitlines():
        heading = None if in_code else re.match(r"(#{1,4})\s+(.+)", line)
        if heading:
            flush()
            trail[len(heading.group(1)) - 1:] = [heading.group(2).strip()]
            continue
        if line.count("`") % 2:     # a code block or a code span opens or closes on this line
            in_code = not in_code
        if not in_code and not line.strip() and sum(len(x) + 1 for x in lines) >= max_chars:
            flush()
        lines.append(line)
    flush()
    return chunks


def load_state():
    if os.path.exists(STATE_FILE):
        with open(STATE_FILE) as f:
            return json.load(f)
    quote = api("POST", "/crawl/quote", json=CRAWL)
    print(f"Quote: {quote['sitemap']['in_scope_urls']} sitemap URLs in scope, {quote['credits_per_page']} "
          f"credits a page, at most {quote['credits_ceiling']} credits")
    job = api("POST", "/crawl", json={**CRAWL, "max_credits": quote["credits_ceiling"]})
    print(f"Started {job['job_id']}")
    return {"job_id": job["job_id"], "after": 0, "written": []}


def save_state(state):
    with open(STATE_FILE, "w") as f:
        json.dump(state, f)


state = load_state()
written = set(state["written"])     # sha256 of the pages already written
pages = chunks = 0
oversized = []
with open("llms-full.txt", "a", encoding="utf-8") as full, open("docs.jsonl", "a", encoding="utf-8") as out:
    while True:
        batch = api("GET", f"/crawl/{state['job_id']}/pages",
                    params={"after": state["after"], "limit": 10, "content": "true"})
        for page in batch["pages"]:     # finished pages only, in a stable order
            if page["state"] != "done":
                print(f"  skipped   {page['url']} ({page.get('error_class')})")   # duplicate, blocked, ...
                continue
            if page["sha256"] in written:
                print(f"  skipped   {page['url']} (same content as a page already written)")
                continue
            markdown = page.get("markdown")
            if markdown is None and page.get("content_url"):   # pages over 2 MB come as a link
                markdown = requests.get(page["content_url"], timeout=120).text
            markdown = (markdown or "").strip()
            if len(markdown) > OVERSIZED:
                oversized.append(page["url"])
                print(f"  oversized {page['url']} ({len(markdown):,} characters): review it")
            full.write(f"Source: {page['url']}\n\n{markdown}\n\n---\n\n")
            parts = chunk(markdown)
            for n, (section, text) in enumerate(parts):
                out.write(json.dumps({
                    "id": f"{page['url']}#{n}",      # stable: an upsert by id makes a replay harmless
                    "url": page["url"],
                    "title": page.get("title", ""),
                    "section": section,
                    "text": text,
                    "page_sha256": page["sha256"],
                }, ensure_ascii=False) + "\n")
            written.add(page["sha256"])
            pages += 1
            chunks += len(parts)
            print(f"  {len(parts):>3} chunks {page['url']}")
        full.flush()
        out.flush()
        state["after"] = batch["next_after"]
        state["written"] = sorted(written)
        save_state(state)
        if batch["has_more"]:
            continue                 # more finished pages are ready now
        if batch["finished"]:
            break                    # the job is over and every page has been read
        time.sleep(5)                # everything final so far is read: ask again in a moment

job = api("GET", f"/crawl/{state['job_id']}")
print(f"{pages} pages, {chunks} chunks; {len(oversized)} oversized; job {job['status']} "
      f"({job['stop_reason']}), {job['credits_used']} credits")
Run it
# Python 3, the script saved as website_to_markdown.py
pip install requests
UJEEBU_API_KEY=your-key python3 website_to_markdown.py

# Node.js 18 or later, the script saved as website-to-markdown.js
UJEEBU_API_KEY=your-key node website-to-markdown.js
Output (trimmed)
Quote: 23 sitemap URLs in scope, 10 credits a page, at most 200 credits
Started c_d8d4a9a2-5b47-4b12-99fd-5b6c9d991522
    2 chunks https://ujeebu.com/docs
    3 chunks https://ujeebu.com/docs/apis
   43 chunks https://ujeebu.com/docs/apis/scrape
   20 chunks https://ujeebu.com/docs/apis/scrape/auto-proxy
  oversized https://ujeebu.com/docs/apis/scrape/extract-rules (63,470 characters): review it
   32 chunks https://ujeebu.com/docs/apis/scrape/extract-rules
  ...
   21 chunks https://ujeebu.com/docs/mcp
    2 chunks https://ujeebu.com/docs/sdks
20 pages, 363 chunks; 2 oversized; job completed (max_pages), 200 credits

The Python and Node.js versions write the same files: on the same job, both produced an identical llms-full.txt and the same 363 chunks.

7

Embed and load

The JSONL file is the hand-off to your own stack. Read it line by line, embed the title, section and text together with the model you use, and upsert each vector by its id. The two functions below are placeholders for your embedding model and your vector store.

import json

def embed(text):            # your embedding model
    raise NotImplementedError

def upsert(id, vector, metadata):   # your vector store
    raise NotImplementedError

with open("docs.jsonl", encoding="utf-8") as f:
    for line in f:
        rec = json.loads(line)
        vector = embed(f"{rec['title']}\n{rec['section']}\n\n{rec['text']}")
        upsert(rec["id"], vector, {"url": rec["url"], "title": rec["title"],
                                   "section": rec["section"], "page_sha256": rec["page_sha256"]})
Keep page_sha256

Store each chunk's page_sha256 with its vector. The next tutorial uses it to re-embed only the pages that changed: Keep a RAG knowledge base in sync with a website.

For a short index of the site rather than its full text, see How to generate an llms.txt file. Page contents and the job archive are kept for 72 hours after the job completes.

Size the site before you convert it

The free sizer lists a site's sitemap URLs and quotes the Markdown crawl before you spend a credit.

?

Frequently Asked Questions

How do I convert an entire website to Markdown?

Start one crawl job with "format": "markdown". It follows the site's links, and its sitemap with "use_sitemap": true, and returns every page as Markdown, 10 credits a page. Read the pages with the cursor and write them where you need them: one llms-full.txt file, or chunks for a vector store.

How do I scrape documentation for an LLM?

Crawl the docs section only, with an include pattern such as /docs/**, the fit Markdown filter to keep the main content, and exclude patterns for changelogs and translated copies. Then cut each page at its headings and keep the URL and heading trail on every chunk, so answers can cite their source.

How do I crawl a website for RAG without noise?

Exclude what adds no knowledge (changelogs, translations, print views), use the fit filter to drop menus and footers, skip duplicate records and pages whose content hash you already wrote, and flag oversized pages for review. The script on this page does all four.

What is llms-full.txt?

A single Markdown file with the full text of a site's documentation, for a language model to read in one go. It complements llms.txt, which lists the pages with one line each. The script on this page writes llms-full.txt and a JSONL file of chunks from the same crawl.

Can I read the pages while the job is still running?

Yes. GET /crawl/{id}/pages returns finished pages only, in a stable order. When has_more is false and finished is false, everything final so far is read: ask again a few seconds later from the same next_after.

How long are the crawled pages kept?

Page contents and the job archive are kept for 72 hours after the job completes; page records and the job status for 7 days. Read the pages, or download the archive, within that window.