GitHub Repository to Clean Markdown for LLM & RAG
Pricing
from $1.00 / 1,000 files processed
GitHub Repository to Clean Markdown for LLM & RAG
Convert any public GitHub repository (or private with a token) into one clean Markdown document with a file tree, ready for LLM context and RAG. Skips lockfiles, binaries and build folders, supports include/exclude filters and chunking. No git clone, pay per file.
Pricing
from $1.00 / 1,000 files processed
Rating
0.0
(0)
Developer
Egor Kramskoy
Maintained by CommunityActor stats
0
Bookmarked
1
Total users
0
Monthly active users
2 days ago
Last modified
Categories
Features
Share
GitHub repo to Markdown in one Apify Actor: send repository URLs and get the whole codebase as one clean Markdown document with a file tree. Use it for repository to LLM context, codebase to Markdown for RAG, or GitHub to text for ChatGPT / Claude. It downloads a single zip archive per repository (no git clone, no browser), skips lockfiles, binaries and build folders, and can split the result into RAG-ready chunks.
What it does
- Accepts
https://github.com/owner/repo,.../repo.git,.../tree/<branch>,git@github.com:owner/repo.gitand plainowner/repo. - Finds the default branch through the GitHub API (renamed repositories are followed). If the API is rate limited it falls back to
main, thenmaster. - Downloads the branch archive from
codeload.github.comand reads it in memory. - Keeps text files only: lockfiles,
node_modules,dist, images, fonts, archives, minified files and binaries are skipped by default. - Puts the README first, then all other files in path order, each in a fenced code block with the right language tag. Fences are lengthened automatically when a file already contains triple backticks (for example Markdown docs).
- Adds an ASCII file tree, word count and a token estimate. Optionally splits the Markdown into overlapping chunks.
Why use it
- LLM-ready: one document you can paste into ChatGPT, Claude or Gemini, or feed into an embedding pipeline.
- Fast and cheap: one HTTP download per repository, pay per file.
- Controllable:
includeExtensions,excludePatterns,maxFilesandmaxFileSizeKbkeep the context small. - Safe failures: a missing repository or a bad URL gives one item with
status: "error"; the run continues with the next URL.
Input example
{"repoUrls": ["https://github.com/tiangolo/typer"],"maxFiles": 20,"includeExtensions": [".py", ".md"],"includeTree": true,"chunkSize": 1500,"chunkOverlap": 200}
| Field | Default | Description |
|---|---|---|
repoUrls | tiangolo/typer (demo) | Repository URLs or owner/repo |
branch | empty | Branch to download; empty = branch from the URL or the default branch |
githubToken | empty | Optional token (stored as a secret) for private repositories and higher rate limits |
maxFiles | 100 | Max files per repository (1-1000); README first, then alphabetical by path |
includeExtensions | empty | Only these extensions, e.g. [".py", ".md"] (case-insensitive, dot optional) |
excludePatterns | built-in list | dir/ excludes a folder anywhere; other patterns match the file name or full path with * and ?. Replaces the default list |
includeTree | true | Add the ASCII file tree to the Markdown |
chunkSize | 0 | Chunk size in characters; 0 disables chunking (max 16000) |
chunkOverlap | 200 | Overlap between chunks; reduced to chunkSize / 4 if not smaller than chunkSize |
maxFileSizeKb | 200 | Files larger than this are skipped (1-2000) |
Output example
One dataset item per repository (long fields shortened):
{"repo_url": "https://github.com/tiangolo/typer","owner": "fastapi","repo": "typer","branch": "master","files_processed": 20,"files_skipped": 640,"tree": "typer/\n├── docs/\n│ └── index.md\n├── typer/\n│ ├── __init__.py\n│ └── main.py\n└── README.md","markdown": "# fastapi/typer\n\n**Branch:** master\n**Files:** 20\n\n## Repository structure\n\n```text\ntyper/\n...\n```\n\n## Files\n\n### `README.md`\n\n```markdown\n...\n```\n","chunks": ["# fastapi/typer\n\n**Branch:** master ...", "...next chunk..."],"word_count": 18250,"estimated_tokens": 31200,"status": "ok","error_message": null}
The values are illustrative. owner and repo are the resolved names, so they can differ from the input URL for renamed repositories. files_skipped counts every file that was left out: excluded, binary, too large, filtered by extension, empty or over maxFiles.
Pricing
Pay-per-event: $0.02 per run start (the run-started event, charged once per run that has at least one URL) plus $0.001 per file (the file-processed event, charged for every file included in the Markdown). Example: one repository with 100 files costs $0.02 + 100 x $0.001 = $0.12. Repositories that fail are not charged per file; runs with no URLs are not charged at all.
The prices are not stored in the Actor code. .actor/pay_per_event.json documents the events and the suggested prices. The real prices are set in Apify Console (Actor > Publication > Monetization).
Use with Claude Desktop / Cursor (MCP)
Connect the Actor to any MCP client through the Apify MCP server: https://mcp.apify.com/?actors=sequined_lacework/github-repo-to-markdown
Add this to your Claude Desktop or Cursor MCP config (mcpServers):
{"mcpServers": {"apify": {"url": "https://mcp.apify.com/?actors=sequined_lacework/github-repo-to-markdown","headers": {"Authorization": "Bearer <YOUR_APIFY_TOKEN>"}}}}
An AI agent can pass a GitHub repository URL and get the file tree plus the source files as one Markdown document, so it can read and explain a codebase without cloning it.
Integrations: n8n and LangChain
n8n
Use the Apify node (operation: Run Actor, then Get Dataset Items) with the Actor ID sequined_lacework/github-repo-to-markdown, or an HTTP Request node (method POST, body type JSON) pointing at the synchronous endpoint, which returns the dataset items directly:
https://api.apify.com/v2/acts/sequined_lacework~github-repo-to-markdown/run-sync-get-dataset-items?token=<YOUR_APIFY_TOKEN>
Body:
{"repoUrls": ["https://github.com/tiangolo/typer"],"maxFiles": 30,"includeExtensions": [".py", ".md"]}
Synchronous runs time out after 300 seconds, so use the regular run endpoint for large inputs.
LangChain (Python)
Install langchain-apify and langchain-core, and set the APIFY_API_TOKEN environment variable. The Markdown is in the markdown field and becomes the document page_content.
from langchain_apify import ApifyWrapperfrom langchain_core.documents import Documentapify = ApifyWrapper()loader = apify.call_actor(actor_id="sequined_lacework/github-repo-to-markdown",run_input={"repoUrls": ["https://github.com/tiangolo/typer"], "maxFiles": 30, "includeExtensions": [".py", ".md"]},dataset_mapping_function=lambda item: Document(page_content=item["markdown"] or "",metadata={"source": item["repo_url"], "repo": f'{item["owner"]}/{item["repo"]}', "branch": item["branch"]},),)docs = [d for d in loader.load() if d.page_content]
To load an existing run instead, use ApifyDatasetLoader(dataset_id="<DATASET_ID>", dataset_mapping_function=...) from langchain_apify with the same mapping function. If you set chunkSize, the chunks field already holds ready-to-embed pieces, so no extra text splitter is needed.
Free plan limits
On the free Apify plan the Actor runs in demo mode:
- At most 1 repository per run; extra repositories are skipped.
- At most 10 files per repository (the lower of 10 and
maxFiles). - You are charged only for files actually processed.
The run never fails because of these limits, and the log and status message say when something was skipped. Upgrade to a paid Apify plan to process the full input.
Related Actors for RAG Pipelines
Build a complete RAG ingestion pipeline with the same clean Markdown output, chunking options and pay-per-event pricing:
- PDF to Markdown for RAG & LLM: PDFs (arXiv, Google Drive, any URL) with tables preserved
- Website & Sitemap to Markdown for RAG & LLM: docs sites, blogs and sitemaps, code blocks preserved
- Podcast RSS & Transcript Extractor for AI/RAG: podcast episodes with publisher transcripts
- GitHub Repository to Clean Markdown for LLM & RAG (this Actor): whole codebases as one Markdown context with a file tree
- RSS, Atom & Substack to Clean Markdown for RAG: blogs and newsletters, full articles from teaser feeds
Limits
- Public repositories work without a token. GitHub allows about 60 API calls per hour per IP address without authentication, and Apify IPs are shared. The Actor makes one API call per repository to find the default branch; when the limit is hit it tries
mainand thenmaster. PassgithubTokenfor private repositories and higher limits, or setbranchexplicitly to skip the API call. - Output is capped at about 8 million characters per repository so that it fits the Apify dataset item limit (~9 MB). Files beyond the cap are skipped and
error_messagesays so (status staysok). LowermaxFilesor useincludeExtensions. WithchunkSizeabove 0 the chunks must fit in the same limit, so very large repositories get truncated chunks. - Archives larger than 200 MB are rejected.
- No Git LFS: LFS files are pointer stubs in the archive and are included as such.
- Binary files, non-UTF-8 files, empty files and files larger than
maxFileSizeKbare skipped. - Only branches are supported (not tags or commit hashes). A branch name with a slash in a
/tree/...URL is not parsed; use thebranchfield instead. - You are responsible for following the license terms of the code you process.
FAQ
Can I convert a private repository?
Yes. Create a GitHub personal access token with read access to the repository and put it in githubToken. The token is stored as a secret and never written to logs or results.
Why do I see repository or branch not found?
The repository does not exist, the branch name is wrong, or the repository is private and no token was given. GitHub answers 404 for private repositories without access.
How do I fit a big repository into an LLM context?
Set includeExtensions (for example [".py"]), add excludePatterns such as tests/ or docs/, and lower maxFiles. Use estimated_tokens to check the size before sending it to a model.
How are tokens estimated? Roughly 4 characters per token, which is a rough figure for English text and code. Use your model's tokenizer for exact counts.
Can I process a subfolder only?
Not directly. Use includeExtensions and excludePatterns to drop the folders you do not need.
Do I need to do anything to run it locally?
pip install -r requirements.txt, then apify run (Apify CLI). Local runs skip charging automatically.