crawl4ai
by unclecode
Open-source web crawler that extracts clean data from websites for AI agents and language models.
- Stars
- 87,782 stars
- Forks
- 9.2k forks
- Last push
- 2 days ago
- Activity
- Active
# Install the library$ pip install -U crawl4ai# Install the browser it uses (once)$ crawl4ai-setup# Turn a page into markdown$ crwl https://news.ycombinator.com -o markdownCommands from the project's README. Run them after installing (see below).
Overview
Understand crawl4ai in 60 seconds
- What it does
- Crawl4AI is an open-source Python web crawler that turns web pages into clean markdown and structured JSON for AI models. It runs a real browser, so it handles JavaScript-heavy pages, and you can use it as a library, a command-line tool or a Docker server.
- The problem it solves
- Web pages are full of menus, ads and scripts that waste an AI model's context. Crawl4AI fetches pages and returns just the useful content, with filters, citations and extraction schemas built in.
- Why choose it
- Choose it for a free Apache-2.0 crawler you fully control in Python, with LLM-ready markdown. The hosted Crawl4AI Cloud adds web search and handles bot walls for you, for a fee.
- Who should use it
- Developers building RAG pipelines from web content
- AI agent builders who need web reading
- Data engineers scraping structured data
- Python users who want a free, self-hosted crawler
- Setup difficulty
You'll need:
- Python 3 with pip
- A Chromium browser, installed by crawl4ai-setup
- Optional: Docker for the server
- Optional: an LLM API key for LLM extraction
How crawl4ai works
This repository is the Apache-2.0 crawler behind Crawl4AI Cloud. You install it with pip, run crawl4ai-setup once to install a browser, and then crawl pages from Python with AsyncWebCrawler or from the terminal with the crwl command.
Its markdown output keeps headings, tables and code, and filters such as BM25 and pruning remove boilerplate. For structured data it offers CSS and XPath extraction schemas that need no LLM, a schema generator, and LLM-based extraction with any provider.
You can also run it as a Docker server with a dashboard and playground on port 11235, secured with your own token. Crawl4AI Cloud is the hosted service with search, SERP and answer endpoints; the README says it includes 1,000 free credits a month.
Features
Key features
LLM-ready markdown
Clean markdown with headings, tables, code and citations.
Content filters
Pruning, BM25 and LLM filters strip menus and boilerplate.
Extraction without an LLM
CSS, XPath and regex schemas pull structured JSON fast.
LLM extraction
Use any LLM provider to fill a typed JSON schema.
Deep crawling
Crawl a site breadth-first with page limits.
Docker server
Self-hosted API with a dashboard and playground.
Strengths
- Free and Apache-2.0 licensed
- Full control over sessions, proxies, cookies and hooks
- Library, CLI and server in one package
- Very popular and actively released
Limitations
- You run the browsers yourself, which uses memory
- Bot walls and proxies are your responsibility when self-hosting
- Web search needs the paid Cloud service
- LLM extraction costs whatever your LLM provider charges
Practical use cases
RAG knowledge base
Crawl documentation pages into markdown for a vector database.
Product data extraction
Use a CSS schema to pull prices and names into JSON.
Agent web access
Give an AI agent a crawler it can call.
Site research
Deep crawl a site with a page limit and read it offline.
Installation
Install crawl4ai
Commands come from Crawl4AI's README. AIRepoHub hasn't run them yet. View source
Prerequisites
- Python 3 and pip
Supported systems
- Windows
- macOS
- Linux
- 1
Install the package
Shellpip install -U crawl4ai - 2
Install the browser
Run once after installing.
Shellcrawl4ai-setup - 3
Check the installation
Shellcrawl4ai-doctor
- 1
Create a token and start the server
The server needs a token; without one it only answers inside its container.
Shellexport CRAWL4AI_API_TOKEN="$(openssl rand -hex 32)"docker run -d -p 11235:11235 --name crawl4ai --shm-size=1g \ -e CRAWL4AI_API_TOKEN="$CRAWL4AI_API_TOKEN" \ unclecode/crawl4ai:latest - 2
Test it
Allow about 10 seconds for it to start.
Shellcurl -s http://localhost:11235/md \ -H "Authorization: Bearer $CRAWL4AI_API_TOKEN" \ -H "Content-Type: application/json" \ -d '{"url": "https://news.ycombinator.com"}' | jq -r .markdown - 3
Open the dashboard
http://localhost:11235/dashboard, with a playground at /playground.
Configuration and API keys
| Setting | What it's for |
|---|---|
CRAWL4AI_API_TOKENOptional | Token that secures the self-hosted Docker server. |
CRAWL4AI_KEYOptional | Your Crawl4AI Cloud API key, only for the hosted service. |
First run
- 1
Crawl a page to markdown
Shellcrwl https://news.ycombinator.com -o markdown - 2
Deep crawl up to 10 pages
Shellcrwl https://docs.crawl4ai.com --deep-crawl bfs --max-pages 10
crawl4ai's documentation doesn't include sample output, so we don't show any. Expect the results in your terminal.
Your first project
Crawl your first page from Python
Fetch a web page and print it as clean markdown.
Before you start
- Crawl4AI installed and crawl4ai-setup run (see Installation)
- 1
Save this as crawl.py
Textimport asynciofrom crawl4ai import AsyncWebCrawlerasync def main(): async with AsyncWebCrawler() as crawler: result = await crawler.arun(url="https://news.ycombinator.com") print(result.markdown)asyncio.run(main()) - 2
Run it
Shellpython crawl.py
What to expect
The script opens the page in a headless browser and prints the Hacker News front page as markdown.
Next steps
- Add a PruningContentFilterLXML to get fit markdown
- Try JsonCssExtractionStrategy for structured data
- Run the Docker server for an HTTP API
Costs and requirements
What it costs to run
- License
- Apache-2.0. Free to use, modify and use commercially.Free
- Library and server
- Free; you cover your own machine or hosting.Free
- Crawl4AI Cloud
- Optional hosted service. The README lists 1,000 free credits a month and plans from $10.Depends
- LLM extraction
- Billed by the LLM provider you choose.Depends
Troubleshooting
Common setup issues
Browser setup fails
Install it by hand with: python -m playwright install --with-deps chromium
Not sure the install worked
Run crawl4ai-doctor to check it.
Docker server refuses requests from outside
Set CRAWL4AI_API_TOKEN when starting it and send it as a Bearer token.
crwl -q asks for a key
Questions need an LLM key; set it with crwl config.
Alternatives
Similar AI repositories
dify
langgenius
Visual workspace for building agentic workflows and RAG pipelines, self-hosted or in the cloud.
graphify
Graphify-Labs
Agent skill that turns a codebase and its docs into a searchable knowledge graph for Claude Code, Cursor, Codex and Gemini CLI.
PaddleOCR
PaddlePaddle
OCR toolkit that reads text from PDFs and images and turns documents into structured data for AI.
hello-agents
datawhalechina
Chinese-language tutorial that teaches how AI agents work and how to build one from scratch.