All tools
Context · free, no sign-up

Will my codebase fit in the model context?

Code tokenises more densely than prose, so a repository that looks small in megabytes can be very large in tokens. Fitting it is one question; using it well is another.

4 inputs4 questions answeredUpdated for 2026 hardware
Codebase Context Planner — Will my codebase fit in the model context?
Answer first

The short answer

Computed from this tool’s default settings — lines of code and the rest as most people start. Change them below for your own case.

Your codebase486K tokens

50,000 lines are about 486K tokens, more than the window holds. Retrieve the relevant files rather than paging the whole repository through the model.

The calculator

Codebase Context Planner

Lines of code to tokens, against real context windows.

Your setup

English prose runs near 4; code is denser, nearer 3.2–3.6.

Your codebase486K tokens

50,000 lines are about 486K tokens, more than the window holds. Retrieve the relevant files rather than paging the whole repository through the model.

Characters1.8M
Share of window380%
Context window128,000
WindowFillsVerdict
8K5,934%Needs 60 passes
33K1,483%Needs 15 passes
131K371%Needs 4 passes
200K243%Needs 3 passes
272K179%Needs 2 passes
1M49%Fits
Inputs

What each setting changes

Every input moves the result for a reason. This is what each one does and where to find the value for your own machine.

SettingDefaultWhat it changes
Lines of code50000Your own figure, starting from 50,000. Change it to match what you actually run.
Average characters per line35Anywhere from 5 to 200.
Characters per token3.6English prose runs near 4; code is denser, nearer 3.2–3.6.
Model context window1280006 options, from 8K to 1M.
Worked examples

Real answers across model context window

The same calculation run at a range of settings, with everything else left at its default. These are computed by the tool itself, not written by hand.

Model context windowYour codebaseCharactersShare of windowContext window
8K486K tokens1.8M5,934%8,192
32K486K tokens1.8M1,483%32,768
128K486K tokens1.8M371%131,072
200K486K tokens1.8M243%200,000
272K486K tokens1.8M179%272,000

50,000 lines are about 486K tokens, more than the window holds. Retrieve the relevant files rather than paging the whole repository through the model.

Method

How this is calculated

No lookup tables and no invented constants. Here is the arithmetic, so you can check it against your own numbers.

Code tokenises more densely than prose because identifiers, punctuation and indentation all consume tokens. Three and a half characters per token is a reasonable working figure for most languages, and it is an input here so you can correct it from a real count.

Fitting is not the same as being used well. Attention quality degrades across a very long window, so a codebase that technically fits in 1M tokens is usually still better served by retrieving the relevant files.

These are well-founded engineering estimates, not benchmark results. Your quantisation, runtime and context length all move the real number, and usable memory is an assumption rather than a specification. See the full methodology for every assumption behind these figures.

Use cases

Who this is for

The three situations that bring people to this calculation.

Use case 01

Coding agents

See whether a repo fits the window at all.

Use case 02

Choosing a model

Match context window to codebase size.

Use case 03

Designing retrieval

Decide when to retrieve rather than stuff.

Walkthrough

How to use this calculator

Four steps, no account, nothing leaves your browser.

  1. Set lines of code

    Start at the top of the panel. Every figure recalculates as you change it — there is no submit button, because watching the number move is the point.

  2. Adjust the rest to match your setup

    3 further settings: average characters per line, characters per token, model context window. Defaults are the common case, so change only what differs for you.

  3. Read the headline, then the table

    The large figure answers the question. The table underneath shows how the answer changes across nearby settings, which is usually where the decision actually gets made.

  4. Check it against the method

    The arithmetic is written out above. If a number looks wrong for your hardware, the assumptions are the first place to look — usable memory and quantisation are the two that vary most.

Questions

Will my codebase fit in the model context: common questions

The questions people ask about this, answered without hedging.

How many tokens is my codebase?

Roughly characters divided by 3.5. Code is denser than prose because identifiers, punctuation and indentation each consume tokens — 50,000 lines is commonly around half a million tokens.

Should I put my whole codebase in the context?

Rarely, even when it fits. Attention quality thins across a very long window and cost rises the whole way. Retrieving the relevant files usually produces better answers for less money.

Do I need a 1M context model for a large repo?

Usually not. Good retrieval over a 128K window outperforms naive stuffing of a million, and it costs a fraction as much per request.

Why do agents re-read files constantly?

Because each turn resends the conversation, and keeping every file in history gets expensive quickly. Selective reading is a cost strategy, not a limitation.

The rest of the set

All 50 run on the same arithmetic, so answers across them agree.

Coverage

Searches this page answers

Different ways of asking the same question, all resolved above.

codebase tokens calculatorhow many tokens is my repocode tokens per linecontext window for codebasellm repo size limittokens per line of codefit codebase in contextwill my codebase fit in the model contextcodebase context plannercodebase context planner onlinefree codebase context planner
Next step

Now find the models that fit

Sizing is only half the problem. Model Radar takes your hardware and shows which models actually run on it, ranked by what they are good at — the same arithmetic as this page, applied to every model worth running.