ToolsAugust 24, 202613 min read
Best local LLM for coding in 2026, ranked by your RAM
Download size, license and context window for 8 models you can actually run, sorted by the memory in your machine, with the cost arithmetic against a cloud API.

The best local LLM for coding in August 2026 is Qwen3 Coder 30B on any machine with 24 GB of memory or more, a 19 GB download that carries a 256K context window and an Apache 2.0 license. On a 16 GB laptop the answer changes to gpt-oss 20b, a 14 GB download that OpenAI's own model card says will run within 16 GB of memory, and on an 8 GB machine it drops again to Qwen2.5 Coder 7B at 4.7 GB.
Every download size below was read off the Ollama library on 28 August 2026 and every license off the model's own card, because the figure that decides whether a model runs on your laptop is the size of the file rather than the parameter count in the headline. So the ranking sorts by that constraint first and by benchmark scores second, and the money argument for going local turns out to be much weaker than most shortlists let on.
What is the best local LLM for coding right now?
Qwen3 Coder 30B is the strongest local coding model that fits a normal desktop, with GLM 4.7 Flash the closest rival at the same 19 GB download. Both are Mixture of Experts models, which means the file on disk holds around 30 billion parameters while only about 3 billion of them fire on any given token. That design is the reason a 19 GB download can reason about a codebase at all instead of only guessing the next line of a function.

Qwen's model card for Qwen3 Coder 30B lists 30.5 billion total parameters with 3.3 billion activated, a native context window of 262,144 tokens, and an extension to 1 million tokens using YaRN. Ollama's page for the same model puts its pretraining at 7.5 trillion tokens with a 70% code ratio. The license is Apache 2.0, the clean one, with no usage reporting and no clause about what you may sell afterwards.
GLM 4.7 Flash comes from Z.ai and ships under MIT, an even shorter license than Apache. Its model card on Hugging Face reports 59.2 on SWE bench Verified, the test that scores a model on real GitHub issues it manages to close. Z.ai measured that itself, so read it as the vendor's own number rather than an independent result, though it is the highest self reported score I could find today on a card for a model this small.
Here is the whole shortlist in one grid. Download sizes are the Ollama library figures as of 28 August 2026, and each license comes from that model's own card rather than from somebody else's roundup.
| Model | Ollama tag | Download | Context | License | Best for |
|---|---|---|---|---|---|
| Qwen3-Coder 30B | qwen3-coder:30b | 19 GB | 256K | Apache 2.0 | 24 GB machines, agentic coding |
| GLM-4.7-Flash | glm-4.7-flash | 19 GB | 198K | MIT | 24 GB machines, fixing bugs |
| Qwen3.6 27B | qwen3.6:27b | 18 GB | 256K | see model card | 24 GB machines, code plus images |
| Gemma 4 26B | gemma4:26b | 19 GB | 256K | Apache 2.0 | 24 GB machines, general work |
| gpt-oss 20b | gpt-oss:20b | 14 GB | 128K | Apache 2.0 | 16 GB laptops |
| Devstral 24B | devstral:24b | 14 GB | 128K | Apache 2.0 | 16 GB laptops, agent harnesses |
| Gemma 4 12B | gemma4:12b | 7.6 GB | 256K | Apache 2.0 | 12 GB machines |
| Qwen2.5-Coder 7B | qwen2.5-coder:7b | 4.7 GB | 32K | Apache 2.0 | 8 GB machines, autocomplete |
2 names are missing on purpose. Qwen3 Coder 480B exists and is genuinely better, but Ollama's page says running it locally requires a minimum of 250 GB of memory, which puts it outside anything you own. The gpt-oss 120b sits in the same bracket at a 65 GB download, comfortable on a 128 GB workstation and impossible on a laptop.
How much memory do you need to run a local coding model?
A local coding model needs roughly its download size in free memory, plus 2 to 4 GB for the operating system, plus more again for the context you fill. Qwen3 Coder 30B is a 19 GB file, so 24 GB of memory is the realistic floor and 32 GB is where it stops feeling tight.

Parameter counts are the wrong unit for this decision. A 30 billion parameter model sounds like it should need 30 GB, but the file you download has been quantized to roughly 4 bits per weight, which is why the Qwen3 Coder 30B tag arrives as 19 GB rather than 60. The same compression is why Gemma 4 26B and GLM 4.7 Flash both land at 19 GB despite being built differently.
On an Apple Silicon Mac the arithmetic is simpler and harsher, because the graphics processor and the main processor share one pool of unified memory. The machine this article was written on is a MacBook Pro with an M3 Pro chip and 18 GB, so a 14 GB model loads with very little room to spare and a 19 GB model will not fit without spilling onto disk. On a Windows or Linux desktop the model wants to sit inside the graphics card's own video memory, and a 24 GB card will hold any 19 GB model here with room for a working context.
The context window costs memory too, and this is where agentic coding gets expensive. A model advertising 256K tokens can only use that window if memory is left over once the weights are loaded. Filling it with repository files, test output and the model's own previous reasoning is what a coding agent does on every turn, so budget for the model size plus several more gigabytes.
- 8 GB, Qwen2.5 Coder 7B at 4.7 GB, useful for autocomplete and short explanations
- 16 GB, gpt-oss 20b or Devstral 24B at 14 GB, comfortable for single file work
- 24 GB, Qwen3 Coder 30B or GLM 4.7 Flash at 19 GB, enough for agentic coding
- 64 GB and up, gpt-oss 120b at 65 GB, the closest a local model gets to a cloud one
Which local coding model fits a 16 GB laptop?
On a 16 GB laptop the pick is gpt-oss 20b, a 14 GB download under Apache 2.0 with a 128K context window, and OpenAI's model card states it will run within 16 GB of memory thanks to MXFP4 quantization of the Mixture of Experts weights. It is the only model in this size class whose maker publishes that memory figure on the card itself rather than leaving you to work it out.

The card lists 21 billion total parameters with 3.6 billion active, so it works the same way as the bigger models here and simply carries fewer experts. In daily use it is the model to reach for when you want an assistant that reads one file and rewrites a function inside it, rather than one that crawls a whole repository.
Devstral 24B is the other 14 GB option and it aims at a different job. Mistral built it for agent harnesses rather than for chat, and its card for Devstral Small states 53.6% on SWE bench Verified, again the maker's own measurement rather than an independent one. It ships under Apache 2.0 with a 128K context window, and Ollama's page describes it as finetuned from Mistral Small 3.1, which is why it feels more like a tool operator than a conversationalist.
Gemma 4 12B is the safety net at 7.6 GB. Google released the Gemma 4 family under Apache 2.0 in sizes it calls E2B, E4B, 26B Mixture of Experts and 31B Dense, with a 128K context on the edge models and up to 256K on the larger ones. The 12B tag on Ollama carries the 256K window, which makes it the smallest model here that can hold a long conversation about a codebase.
If you have exactly 16 GB and nothing else running, gpt-oss 20b is the answer. With 16 GB and a browser holding 40 tabs behind your editor, Gemma 4 12B leaves your machine usable while it thinks, and a model you can actually run beats a better one that swaps to disk on every reply.
Which local coding model wins on 24 GB or more?
On 24 GB or more the winner is Qwen3 Coder 30B, a 19 GB download with a 256K context window on its Ollama tag and an Apache 2.0 license, built specifically for agentic coding rather than adapted to it. GLM 4.7 Flash matches the download size and beats it on self reported benchmark scores, so the choice between the 2 comes down to context length against license preference.

Qwen3 Coder was trained with what Qwen's own page describes as execution driven reinforcement learning, meaning the model was rewarded for code that actually ran rather than code that looked correct. The 70% code ratio inside its 7.5 trillion token pretraining is the other reason it behaves differently from a general model that happens to know Python, and the effect you feel is fewer confident answers that fall over on the first test run.
GLM 4.7 Flash is the one to try if your work is fixing bugs in an existing repository rather than writing features from scratch. Its 59.2 on SWE bench Verified is a score on real issues from real projects, and Z.ai's own description on Ollama calls it the strongest model in the 30B class. That is the vendor talking about its own model, and the card's numbers are the only evidence offered, so treat the ranking as a claim and the 59.2 as the basis for it.
Gemma 4 26B and Qwen3.6 27B round out the tier at 19 GB and 18 GB. Both carry 256K context windows and both read images as well as text, which matters if you want to paste a screenshot of a broken interface into the conversation. Gemma 4 26B activates 3.8 billion of its 25.2 billion parameters, and Ollama's tag for Qwen3.6 27B describes it as built for agentic coding with what the page calls thinking preservation across turns.
The context window Ollama ships on the tag is often lower than the maximum printed on the model card, and that gap deserves to travel with you into this decision. Qwen2.5 Coder is the clearest example, with a card that advertises a full 131,072 tokens and an Ollama tag that lists 32K. You get the tag's window, not the card's, and nobody warns you at download time.
What do you install to run a local coding model, and what does it cost?
You install either Ollama or LM Studio, and both cost nothing for local models. Ollama is published under the MIT license with its source on GitHub, and its most recent release when this was written is v0.33.1, dated 26 August 2026.

Ollama is the one to pick if you are comfortable in a terminal, because it turns the whole process into a single command per model and exposes a local address that coding tools can talk to. You download it from the Ollama download page, which covers macOS, Windows and Linux.
This first command downloads the model onto your disk, and nothing else happens until it finishes.
ollama pull qwen3-coder:30bYou should see a progress bar that climbs to 100% and then hands your prompt back. The file lands in your home folder under .ollama/models on macOS, and running ollama ls afterwards prints the model beside its size, which is how you confirm the full 19 GB really arrived.
The second command opens a conversation with the model you just downloaded, in the same terminal window.
ollama run qwen3-coder:30bThe first answer takes noticeably longer than every answer after it, because the weights are being read off disk into memory on that opening request. If your machine is short on memory you will feel it here as a wait of a minute or more, which is the honest signal that you picked a model one size too big.
LM Studio is the same idea with a window instead of a terminal. Its pricing page lists a Free plan at $0, described as running local models and voice transcription on your own machine with no data ever leaving your device, alongside a separate pay as you go option for cloud models priced between $0.13 and $3.00 per million input tokens. For every model here you never touch the paid side.
Neither tool needs an account for local models, neither sends your code anywhere, and both read the same model files off your disk. If you want to see what a model looks like inside a real automation rather than a chat window, the walkthroughs on the tutorials desk build agents step by step with every prompt printed in full.
Does running a local LLM for coding actually save money?
Mostly no, and the arithmetic is short enough to check yourself. Anthropic publishes a worked example of a 1 hour coding session that consumes 50,000 input tokens and 15,000 output tokens, and at Claude Sonnet 5's published rate of $2 per million input tokens and $10 per million output tokens, that session costs $0.25 in tokens.

Run 20 of those sessions in a month and you have spent $5.00. Run 80 and you reach $20, which is what Claude Pro costs billed monthly, or $17 a month if you pay $200 up front for a year. For one developer coding a few hours a day, the cloud bill is already smaller than the hardware headroom local inference quietly asks for.
The picture does change at the top of the range. Anthropic's same example run on Claude Opus 5 at $5 per million input tokens and $25 per million output tokens comes to $0.705 once the $0.08 session runtime charge is added, which is close to 3 times the Sonnet 5 figure for identical work. A team running agents in loops overnight, or anyone pushing a whole repository through the context window on every turn, will reach numbers where local hardware pays for itself. Somebody writing functions between meetings will not.
So the honest reasons to run a local LLM for coding have nothing to do with money. Your code never leaves the machine, which settles the question for anyone under a client contract that forbids sending source to a third party. There is no rate limit and no slowdown at 5pm on a Tuesday when everybody else is hammering the same servers. And the model keeps working on a plane, inside a network with no outbound access, and on the morning your provider has an outage.
The fourth reason is quieter and it compounds over time. A model sitting on your disk cannot be deprecated out from under you, and the Apache 2.0 and MIT licenses on these files mean the copy you downloaded keeps behaving the same way in 2 years. If you have ever rewritten a prompt because a provider shipped a new version that answered differently, that stability has a value your accounting software will never show you.
Where does a local coding model still lose to Claude or GPT?
A local coding model loses on raw speed, on the wait after a cold start, and on the hardest reasoning tasks where the gap is still wide. GLM 4.7 Flash's self reported 59.2 on SWE bench Verified is a genuine achievement for a file that fits on a memory stick, and it also sits well below what the frontier cloud models score on the same test.

Speed is the wall most people hit first. Alex Ewerlöf, who wrote up his own experiments with local models for agentic coding, reports generation as slow as 1 to 2 tokens per second for a 31 billion parameter model on his AMD laptop processor, a rate he calls unacceptable for real work. That is one person on one machine, but the shape of it holds everywhere, because a model that spills out of fast memory falls back to slower memory and loses an order of magnitude.
The second wall is the context window in practice rather than on the tag. A coding agent loads files, runs tests, reads the output and feeds all of it back with its own reasoning attached, so it burns through context far faster than a chat does. A 256K window your memory can only fill to 32K is a 32K window, and the failure mode is not an error message but a model that quietly forgets the file it read 10 turns ago.
The third gap is tool use. The frontier cloud models have been trained hard on calling tools reliably and recovering when a call comes back wrong, and the local models are behind on that specific skill even where their raw code quality is close. If you are wiring a model into an agent that has to run commands, read results and decide what to do next, expect to supervise a local model more closely. The work on the agents desk shows what that supervision looks like once an agent is running on a schedule.
None of this argues against downloading one tonight, only for knowing which job you hand it. Local models are strong at reading code and writing a function against a clear specification, offline and at no marginal cost, and they are weaker at long autonomous runs where nobody is watching the output.
Which local LLM for coding should you download tonight?
Start with the model that matches your memory rather than the one at the top of the table, because a model that fits will run and a model that does not will swap to disk and waste your evening. On 24 GB or more, download Qwen3 Coder 30B and give it a real task out of your own repository. On 16 GB, take gpt-oss 20b. On 8 GB, take Qwen2.5 Coder 7B and use it for autocomplete and explanations instead of whole features.
Then test it twice, once on something you already know the answer to and once on something you do not. The first run tells you whether the model understands your stack, and the second tells you whether you can trust it without reading every line, which decides whether it stays on your disk past the weekend. A model that passes the first and fails the second is still worth keeping, just never unsupervised.
Keep your cloud subscription running that month while you find out. The $20 you might save is worth less than the hours lost fighting a model one size too small for your work, and running both side by side is the only honest way to learn where your own line sits. More comparisons live on the tools desk, and the releases that will reshuffle this ranking get covered on the AI desk as they land.
Questions people ask
What is the best local LLM for coding on a 16 GB MacBook?
On a 16 GB MacBook the best local LLM for coding is gpt-oss 20b, a 14 GB download that OpenAI's model card says will run within 16 GB of memory. Devstral 24B is the same download size and aims at agent workflows rather than chat. If the machine is also running a browser and an editor, Gemma 4 12B at 7.6 GB leaves far more room to work.
How much RAM do I need to run a local LLM for coding?
Plan for the model's download size, plus 2 to 4 GB for the operating system, plus more again for the context you fill. That makes 8 GB workable for a 4.7 GB model such as Qwen2.5 Coder 7B, 16 GB the floor for the 14 GB models, and 24 GB the realistic entry point for the 19 GB models such as Qwen3 Coder 30B.
Is Ollama free to use?
Yes. Ollama is published under the MIT license with its source on GitHub, and downloading and running local models through it costs nothing. Its most recent release when this was written is v0.33.1, dated 26 August 2026. LM Studio is the other free option, listing a Free plan at $0 for local models on its own pricing page.
Are local coding models good enough to replace Claude or ChatGPT?
For reading code, explaining it and writing functions against a clear specification, a 19 GB local model gets close enough that most developers would not notice the difference day to day. For long autonomous agent runs with heavy tool use, the frontier cloud models are still clearly ahead. GLM 4.7 Flash reports 59.2 on SWE bench Verified by its maker's own measurement, which is strong for its size and still below the frontier.
Can I use these local coding models at work?
Qwen3 Coder 30B, gpt-oss 20b, Devstral 24B, Gemma 4 and Qwen2.5 Coder 7B all ship under the Apache 2.0 license, and GLM 4.7 Flash ships under MIT. Both licenses allow commercial use, redistribution and building products on top with no royalties and no usage reporting. Read the specific model card before you deploy anyway, because a family license does not always cover every single variant.
Does a local LLM for coding work with no internet connection?
Yes, once the model file is sitting on your disk. Both Ollama and LM Studio run the model on your own hardware, and no request leaves the machine while it generates an answer. You need a connection only for the initial download, which runs from 4.7 GB to 19 GB depending on the model you picked.
Which local coding model has the longest context window?
Among the models that fit consumer hardware, Qwen3 Coder 30B, Gemma 4 26B and Qwen3.6 27B all list 256K context windows on their Ollama tags, and Qwen's card for Qwen3 Coder 30B describes a native 262,144 token window extendable to 1 million tokens using YaRN. What your machine can actually hold is usually far less, because the context competes with the weights for the same memory.
