GitLab to Text: Convert GitLab Repos Into LLM-Ready Files
The fastest GitLab to text route is to paste a GitLab.com project URL into Repo2Txt's GitLab converter, add a read-only personal access token, tick the files you want and export one.txt or.md file. Self-hosted instances are not supported directly: download or clone the project, then convert the folder locally.
That is the short answer. The rest of this guide covers what the output looks like, why a token now matters even for public projects (GitLab.com changed its rate limits in October 2026), which token scope to pick, what to do on a self-managed instance, and how to keep the file small enough that a model can actually use it.
What does a GitLab to text export actually contain?
A useful export is one document that holds two things a model needs together: the shape of the project and the contents of the files that matter. Repo2Txt's output starts with a directory tree, then lists each selected file under a --- path --- header. You choose whether the tree shows the full repository or only the files you selected.
An abridged, illustrative example for a small Python service looks roughly like this:
billing-service/
├──.gitlab-ci.yml
├── README.md
├── pyproject.toml
├── src/
│ └── billing/
│ ├── __init__.py
│ ├── api.py
│ └── invoices.py
└── tests/
└── test_invoices.py
---.gitlab-ci.yml ---
stages: [test, deploy]
...
--- src/billing/invoices.py ---
from decimal import Decimal
...
The path headers are the part people underrate. When a model says "the bug is in invoices.py, line 40", it can only say that because every file arrived labelled. Paste five files without headers and you get answers like "in the second function you showed me", which is useless once the chat gets long.
Alongside the text, the tool shows an approximate count of tokens, words, characters and files. Treat the token figure as an estimate. Different models use different tokenizers, so the same file can count a little higher or lower depending on where you paste it.
How do I convert a GitLab repository to a text file?
Here is the full flow with the GitLab repo to text converter, from URL to a file you can paste into ChatGPT, Claude, Gemini or a coding assistant.
Copy the project URL from your browser's address bar, for example the page of
my-group/billing-serviceon GitLab.com. Use the project's main page rather than the URL of a single file, an issue or a merge request.Open the GitLab repo to text converter and paste the URL.
Add a personal access token if the project is private. For a public project the token is optional, but read the next section before you skip it.
Load the file tree. The tool reads the repository through the GitLab API, directly from your browser, and shows every file and folder as a checkbox tree.
Narrow the selection. Start with the Code Only preset, or Deselect all and tick folders by hand. Use the extension filters to drop whole file types such as
.svg,.snapor.csvin one go.Choose the directory tree mode. Full repository tree if the model should know what else exists; selected files only if you want the shortest possible output.
Generate and check the counts. Look at the token estimate before you copy anything. If it is close to your model's context window, go back to step 5.
Export. Copy to the clipboard, download as
.txtor.md, or download the selected raw files as a ZIP if you want to attach them individually instead.
Jupyter notebooks in the project come out as readable cells rather than raw JSON, so a notebooks/ folder does not turn into thousands of lines of metadata and base64.
One thing the GitLab page does not have: the "Smaller output" switch that the GitHub and local-folder tools offer for dropping comment-only lines, lockfiles and minified files. On GitLab you do that trimming yourself through the checkbox tree and extension filters, which is why the selection advice later in this post matters more here.
Why should you add a token even for a public GitLab project?
Because GitLab.com now gives anonymous traffic very little room. In a September 2026 announcement, GitLab said that from October 19, 2026, a request that arrives without credentials gets 60 requests per hour per IP address. WorkOS pointed out in a September 2026 analysis that the previous anonymous limit was 500 requests per minute, roughly a 500-fold cut for anyone who never signs in.
Signed-in users on the Free plan get a sustained limit of 5,000 requests per hour, according to GitLab's rate limits documentation. GitLab says Premium (15,000 per hour) and Ultimate (25,000 per hour) move to their new limits in January 2027. The older per-minute ceiling also stays in place, and whichever limit is lower applies.
Why does that matter for a GitLab to text conversion? Any tool that reads a repository through the API needs more than one request. GitLab's repository tree endpoint is paginated, and fetching file contents through the API is typically done file by file. The exact number of calls depends on the tool, but a project with a few hundred files can plausibly run past 60 requests in one go. The anonymous allowance is also shared with everything else on your IP address: a colleague on the same office network browsing GitLab, a CI runner behind the same NAT gateway, or your own earlier attempt.
When you hit the ceiling, GitLab returns HTTP 429 Too Many Requests with a Retry-After header. GitLab's own advice in the announcement is simple: authenticate. A personal access token moves your requests off the anonymous pool and onto your plan's limit.
So the practical rule for late 2026 onward: create one read-only token and use it for public projects too. It costs two minutes and removes the most common reason a conversion fails halfway.
How do I set up a GitLab personal access token for private repositories?
A personal access token (PAT) is a password substitute that GitLab scopes to specific permissions. Repo2Txt's GitLab tool needs only read access to the API, so the token should carry nothing more.
Creating the token, step by step
GitLab's current documentation describes the path like this:
In GitLab, select your avatar in the upper-right corner.
Select Edit profile.
In the left sidebar, select Access > Personal access tokens.
Choose to generate a new token. Give it a name you will recognise later, such as
repo2txt-readonly, and a short description.Set an expiration date. Pick the shortest window that covers your work, a week or a month rather than a year.
Tick the read_api scope and nothing else.
Create the token and copy it immediately. GitLab shows the full value only once.
Paste it into the token field on the converter.
GitLab has reorganised this menu a few times across versions, so if an older instance shows User Settings > Access Tokens instead, it is the same screen.
Which scope: read_api or read_repository?
This is where most "why doesn't my token work" questions come from. GitLab's access token scopes documentation describes them as follows:
Scope | What GitLab says it grants | Use it for |
|---|---|---|
| Read access to the API for the token's scope | Browser tools and scripts that list trees and read files through the REST API, including Repo2Txt's GitLab converter |
| Read access (pull) to repositories |
|
| Read and write (pull and push) to repositories | Pushing code. Not needed for any export |
| Full read and write API access | Avoid for this job. Far more power than a read-only export needs |
The split is simple once you see it: read_api is for the API, read_repository is for Git. If you plan to use both the web tool and a local git clone (the self-hosted workaround below), either create two narrow tokens or one token with both read scopes. Never reach for api just because it makes an error go away.
Fine-grained tokens
GitLab also offers fine-grained personal access tokens, which grant named permissions on specific resources instead of broad scopes. Third-party documentation, including CodeRabbit's GitLab setup guide, reports them as generally available from GitLab 19.2 on all tiers. They are a good fit for long-running automation. For a quick export, Repo2Txt documents the classic read_api scope, so that is the safe choice.
Expiry, storage and cleanup
GitLab removed the ability to create non-expiring personal access tokens in GitLab 16.0. Its documentation gives a default maximum lifetime of 365 days, and from GitLab 17.6 administrators can extend the ceiling to 400 days with a feature flag. You will not be allowed to make a forever token, which is a good thing.
On Repo2Txt, the GitLab requests go from your browser straight to the GitLab API rather than through a Repo2Txt server. Even so, treat the token like any credential: use it on a machine you trust, and revoke it from the same Personal access tokens page when the project is done. Revoking takes one click and makes the token worthless everywhere.
What about self-hosted GitLab instances?
Repo2Txt's GitLab converter works with GitLab.com only. Self-hosted (self-managed) GitLab is not supported, so a project URL on your company's own GitLab host will not load.
That limit matters less than it sounds. If you can reach the instance, you can get the code onto your machine, and from there Repo2Txt's local folder tool reads it entirely in the browser with nothing uploaded. For code that sits behind a corporate VPN, that is usually the route your security team prefers anyway.
GitLab's rate limit changes from October 2026 also do not apply here. GitLab says Self-Managed and Dedicated limits stay with whoever operates the instance.
Route 1: download the source archive
Every GitLab project page has a Code button with download options for the source as .zip or .tar.gz. Download the .zip, then drop it on Repo2Txt's local folder tool, which accepts ZIP files directly. You get the same checkbox tree and --- path --- output as the GitLab converter.
Two quirks of archives: they contain tracked files only (no node_modules, no build output, unless someone committed them), and archives built with git archive skip any paths marked export-ignore in .gitattributes. If a folder you expected is missing, check that file.
Route 2: shallow clone
If you want a specific branch, or you live in the terminal, clone just the latest commit. Set REPO_URL to the HTTPS clone URL from the project's Code button, then:
git clone --depth 1 --branch main "$REPO_URL" api
Git will ask for a username and password. Paste a personal access token with read_repository scope as the password. GitLab's documentation notes that the username is ignored when you authenticate with a personal access token, so any non-empty value works. Avoid putting the token inside the URL itself, because it then lands in your shell history and in .git/config.
Then drag the api/ folder into the local folder tool. It follows .gitignore files, skips binary files and puts a placeholder in place of the content of any file over 1 MB, so a stray data dump does not swamp the output. The local tool also has the "Smaller output" option that the GitLab page lacks.
Route 3: a CLI packer
If you would rather stay in the terminal end to end, open-source CLIs do the same packing step on a local checkout. From inside the cloned api/ folder, npx repomix writes a single packed file of the repository, and code2prompt. builds a prompt from the directory with token counting:
cd api
npx repomix
code2prompt.
Gitingest's release notes, as listed on the Umbrel app store, mention support for self-hosted GitLab instances and custom Git domains, so it is another option if you want a tool that can point at the instance directly.
How do you turn a GitLab repo into a single file for an LLM that the model can use?
Getting everything into one file is easy. Getting the right things into one file is the real work. A model with a large context window can still lose track of details buried in tens of thousands of tokens of noise, and every token of noise is one less token of answer.
What to deselect first
These are the usual offenders, roughly in order of how much they cost:
Lockfiles:
package-lock.json,yarn.lock,pnpm-lock.yaml,poetry.lock,Cargo.lock,Gemfile.lock. Hashes and version pins that answer almost no question. Keep the manifest (package.json,pyproject.toml), drop the lock.Vendored dependencies:
vendor/,third_party/, any library someone copied into the repo. The model already knows what the library does.Generated code: protobuf and OpenAPI clients, ORM migration snapshots,
*.pb.go,*_generated.ts. Include the.protoor the OpenAPI spec instead; it is the source of truth and far shorter.Minified and bundled assets:
*.min.js,dist/,public/build/, source maps.Test snapshots and fixtures:
__snapshots__/, large JSON fixtures, recorded HTTP cassettes. Keep two representative examples if the question is about tests.Binary-ish text: SVGs, large CSVs, translation files for 30 languages when you only care about one.
The extension filters handle most of this in a few clicks. Untick .lock, .svg, .snap and .csv, then glance at the token count again.
What to keep, especially on GitLab
Keep the files that explain intent: the README, the manifest, entry points, the modules your question is about, and their direct imports.
On GitLab specifically, keep .gitlab-ci.yml and anything it include:s. That file is where build commands, test commands, environment variables, Docker images and deploy targets live together. With it in context, a model can answer "why does this pass locally but fail in the pipeline?" from evidence instead of guessing. If the project uses CI templates from another repository, those included files are not in this project, so paste the relevant template separately.
Full tree vs selected-files tree
When you select one service out of a monorepo, choose the full repository tree. The model then knows that services/payments/ and libs/auth/ exist even though their contents are not included, and it can tell you "this probably lives in libs/auth" rather than inventing a helper. The tree costs a few hundred tokens for most projects, which is cheap context.
When you are sending a tight bundle of five files for a focused question, the selected-files tree keeps things tidy.
Check the count against the model, not against a guess
Context windows differ between models and between plans of the same product, and they change often. Look up the documented limit for the exact model you are using, then compare it with Repo2Txt's approximate token count. Leave generous room for the model's answer and your follow-up questions; a file that fills the whole window leaves nothing for the conversation.
If the export is too big, split it by area rather than truncating: one export for src/api/, another for src/workers/, each with the full repository tree on top so the model keeps its bearings.
Is there a GitLab to txt online tool that doesn't need a clone?
Yes. Several tools do some version of this job, and they make different trade-offs on privacy, hosting and features. Here is how they compare for GitLab specifically, based on each project's own documentation.
Tool | How you run it | GitLab.com | Self-hosted GitLab | Where the code is processed | Notable trade-off |
|---|---|---|---|---|---|
Repo2Txt GitLab converter | Web page, no install | Yes, public and private with a token | No; use the local folder tool on a clone or ZIP | API calls go from your browser to GitLab | No "Smaller output" switch on the GitLab page; GitLab.com only |
Repo2Txt local folder tool | Web page, no install | Via a downloaded ZIP or clone | Yes, via ZIP or clone | Entirely in your browser, nothing uploaded | You need the files on disk first |
Repomix | CLI ( | Yes, on a local clone | Yes, on a local clone | On your machine | Needs Node.js; more output options (XML, Markdown, plain) and config files |
code2prompt | CLI (Rust binary) | Yes, on a local clone | Yes, on a local clone | On your machine | Template-driven prompts; terminal workflow only |
Gitingest | Website, Python package, CLI | Yes | Release notes mention self-hosted GitLab support | Hosted site processes on its server; CLI runs locally | Hosted version means your code passes through a third party |
Where the others win: Repomix and code2prompt are better if you want a scripted, repeatable export in a Makefile or CI job, since Repo2Txt has no API or CLI. Gitingest's ability to point at a self-hosted instance is something Repo2Txt's GitLab page does not do.
Where Repo2Txt fits: you are in a browser, you want to see the file tree and click through what goes in, you want a token estimate before you paste, and you do not want to install anything or create an account. The tools are free with no paid plan.
How do I export a GitLab project as plain text from the command line?
Sometimes you want a file you can regenerate with one command, for example in a scheduled job that refreshes a "codebase snapshot" for an internal assistant. Plain Git can do it without any extra tool.
First, a warning about GitLab's built-in Export project feature under project settings. It produces a migration archive meant for importing into another GitLab instance, with the repository packed as a Git bundle alongside project metadata. It is the wrong shape for an LLM: you would still have to unpack and flatten it.
Instead, work from a clone, again with REPO_URL set to the project's HTTPS clone URL:
git clone --depth 1 "$REPO_URL" billing-service
cd billing-service
git grep -I --name-only -e '' \
| grep -v -E '(^|/)(package-lock\.json|yarn\.lock|poetry\.lock)$' \
| while IFS= read -r f; do
printf -- '--- %s ---\n' "$f"
cat -- "$f"
printf '\n'
done >../billing-service.txt
How this works:
git grep -I --name-only -e ''prints every tracked file that Git does not consider binary. That gives you.gitignorebehaviour for free, because untracked and ignored files never appear.The second
grep -vdrops lockfiles. Add patterns for anything else you want gone, such as\.min\.js$or^vendor/.The loop writes each file under the same
--- path ---style header, so the result reads like the browser tool's output.
To add a directory tree on top, tree --gitignore (tree 2.0 and later) or git ls-files piped through a small formatter both work. Count tokens with whatever tokenizer your model provider documents, or paste the file into a tool that estimates them.
The script is fine for automation. For one-off exports where you want to see and adjust the selection, clicking through a tree is faster than editing regular expressions.
How does the GitLab flow differ from the GitHub one?
If you have used the GitHub repo to text converter on the Repo2Txt home page, most of the GitLab flow will feel the same: URL in, checkbox tree, presets, extension filters, directory tree, --- path --- headers, approximate token count, copy or download. The differences are worth knowing before you switch between them.
URLs. The GitHub tool accepts URLs that point at a branch, tag or subfolder (
tree/<ref>/<path>). On the GitLab page, start from the project URL and narrow the selection with the checkbox tree.Token scope. GitHub uses a personal access token for private repositories and higher rate limits, kept in your browser's local storage. GitLab uses a GitLab token with
read_apiscope.Smaller output. GitHub and local folders have the "Smaller output" option (comment-only lines and extra blank lines removed, lockfiles, minified and generated files skipped), plus an option to replace images with
[image]and a switch for notebook cell outputs. The GitLab page does not, so trim with filters.Hosts. The GitHub tool talks to GitHub; the GitLab tool talks to GitLab.com. Neither connects to self-hosted instances; the local folder tool covers both cases.
What goes wrong most often, and how do you fix it?
"Project not found" on a project you can open in the browser. GitLab answers requests for private projects you cannot access with 404 Not Found rather than 403, so it does not reveal that the project exists. If the project is private and you have not added a token, that is the cause. Add a read_api token from an account that is a member of the project.
It worked yesterday, today it fails. Check the token's expiry date on the Personal access tokens page. Expired tokens fail like missing ones. Also check whether you or an admin revoked it.
Token added, still refused. The scope is the usual suspect. A token with only read_repository is meant for Git over HTTPS, not the API. Create a token with read_api.
429 Too Many Requests. Since October 19, 2026, unauthenticated GitLab.com traffic is capped at 60 requests per hour per IP. Add a token. If you already use one on the Free plan, you are working within 5,000 requests per hour; wait for the Retry-After interval and select fewer files.
Wrong branch. If you need code from a feature branch rather than the default branch, the dependable route is to clone that branch with git clone --depth 1 --branch feature/x "$REPO_URL" and use the local folder tool.
The output is huge. Usually one of three things: a lockfile, a vendored library, or a fixtures folder. Sort them out with the extension filters before you blame the model's context window.
Self-hosted URL rejected. Expected. Use the ZIP download or a clone and the local folder tool, as described above.
What should you ask the model once the file is ready?
The export is only half the prompt. A few patterns that fit GitLab projects well:
Merge request review with context. Paste the export of the directories the merge request touches, then the diff from the MR's Changes tab underneath. Ask what else calls the changed functions and what could break. A diff alone rarely shows the callers.
Pipeline debugging. Include
.gitlab-ci.yml, the Dockerfile, the manifest and the failing job's log. Ask the model to trace which job, image and command produced the failure.Onboarding. Full repository tree, README, entry points and one representative module. Ask for a walkthrough of how a request flows from the entry point to the database.
Documentation. One module plus its tests. Ask for a README section or docstrings in the style the code already uses.
Upgrade planning. Every file that imports the library you are upgrading, found with
git grep -l 'from oldlib', then ask for a list of call sites and the change each one needs.
In each case, say up front which files are included and which are deliberately left out. A one-line note such as "only src/api/ is included; libs/ exists but is omitted" stops the model from assuming missing code does not exist.
For your first GitLab to text export, start with the public project you know best, add a read-only token, and watch the token count while you untick lockfiles. Once that feels routine, the same habits carry over to private and self-hosted projects through the routes above.
Frequently asked questions
Does Repo2Txt's GitLab converter work with self-hosted GitLab?
No. Repo2Txt's GitLab converter talks to GitLab.com only, so a project on a self-managed instance will not load. The workaround is to download the project as a.zip from its Code button, or shallow-clone it, and open the result in Repo2Txt's local folder tool. That tool reads the files in your browser without uploading them and produces the same tree and path-headed output.
Which GitLab token scope do I need to convert a private repository?
Repo2Txt's GitLab converter needs a personal access token with the read_api scope, which GitLab describes as read access to the API. The read_repository scope is meant for Git over HTTPS, such as git clone, and is the one to use if you clone instead. Avoid the full api scope: an export never needs write access. Set a short expiry and revoke the token afterwards.
Why do I get 429 errors when converting a public GitLab project?
Since October 19, 2026, GitLab.com limits requests without credentials to 60 per hour per IP address, shared with everyone on that IP. Reading a repository through the API takes many requests, so large public projects can hit that ceiling. Adding a read-only personal access token moves you onto your plan's limit, which GitLab lists as 5,000 requests per hour on the Free plan.
Is my code uploaded to a Repo2Txt server when I convert a GitLab repo?
For the GitLab converter, the requests go from your browser directly to the GitLab API rather than through a Repo2Txt server. The local folder tool goes further: files are read entirely in the browser and nothing is uploaded. Repo2Txt's document converters and Web2Txt are different, because they send data to a server for conversion.
How do I convert a GitLab repo to a single file for ChatGPT or Claude?
Paste the GitLab.com project URL into Repo2Txt's GitLab converter, add a read_api token if the project is private, untick lockfiles, vendored code and generated files, then generate. You get one file with a directory tree at the top and each file under a '--- path ---' header, plus an approximate token count to compare with your model's context window before you paste.