Best Local LLM for Coding: What to Run on Your Hardware

There is no single best local LLM for coding, and anyone who hands you one model name is answering a narrower question than the one you asked. The right model for your desk comes down to two unglamorous facts: how much memory your computer has, and whether you want inline autocomplete, a chat window to paste code into, or an agent that edits files on its own. Sort those two out and the shortlist picks itself.

The gap between local and cloud has closed enough that this is a genuine choice now, not a hair-shirt exercise. A 7-billion-parameter coding model that fits on a thin laptop can draft functions, explain a stack trace, and finish the line you are halfway through typing. It still won’t match a frontier cloud model on a tangled refactor across dozens of files, and going in expecting that is how people quit in week two. If you are still deciding how much memory to buy for this kind of work, our RAM for local AI guide sizes that question on its own. Here I’m assuming the machine already on your desk is the one you’ll use.

Every size below comes from the Ollama model library this week, because download size is the honest proxy for whether a model will even load. These models are free to run, so cost isn’t the deciding factor. Memory is.

NVIDIA RTX GPU die surrounded by AI software tool icons that run local models on RTX PCs
Image: NVIDIA newsroom

Table of Contents

Start with two questions, not a leaderboard

Skip the benchmark tables for a minute. The first question is how much memory the model can occupy. When you run a model through Ollama or llama.cpp, it loads into RAM or, if you have a discrete GPU, into video memory. The download size at 4-bit quantization is close to that footprint, so a 9GB model needs roughly 9GB free plus a couple of gigabytes of headroom for the context window. A 16GB laptop comfortably holds a 9GB model with room for your editor and browser; a 24GB graphics card holds a 19GB one.

The second question is what you actually want the model to do. Inline autocomplete, conversational help, and autonomous file editing are three different jobs, and the model that wins one can lose another. A tiny model that suggests the end of your current line in fifty milliseconds is useless as an agent, and a 30-billion-parameter agent is overkill for closing a bracket. Answer both questions and you have narrowed a field of hundreds down to two or three.

The best local LLM for coding by memory tier

The best local LLM for coding on your machine is mostly the largest capable model your memory can hold, so start from the hardware rather than the leaderboard.

On 8GB of RAM and no dedicated GPU, Qwen2.5-Coder 7B is the sensible default. At Q4_K_M it downloads at 4.7GB and leaves enough room to keep working. If even that feels tight on an older laptop, the 1.5B version is under a gigabyte and still handles autocomplete and small edits, though it gets lost on anything that needs real reasoning.

With 16GB you move up a tier. Qwen2.5-Coder 14B (9.0GB) and DeepSeek-Coder-V2 16B (8.9GB) both fit with headroom, and the DeepSeek model is a mixture-of-experts design, so it runs faster than its total size suggests because only a fraction of its parameters fire per token. Codestral 22B (13GB) also loads on 16GB, but it gets snug once you feed it a long file.

At 24GB of video memory or a 32GB laptop, the interesting options open up. Qwen3-Coder 30B downloads at 19GB and is a mixture-of-experts model with only about 3.3 billion active parameters per token, which is why a 30B model still feels quick on a single card. Devstral 24B (14GB) and OpenAI’s gpt-oss 20B (14GB, Apache 2.0) sit in the same tier and both leave room to spare.

Above that you’re into workstation territory. DeepSeek-Coder-V2’s full 236B build is a 133GB download, and Qwen3-Coder’s 480B version is 290GB. Both are genuinely capable and genuinely out of reach for a normal desk, so I’d send most people back down the list rather than shopping for a second power supply.

Bar chart comparing the best local LLM for coding options by download size in GB
Even a 30B coding model loads on a 24GB card. Chart: thedeskbrief.com

Autocomplete, chat, and agents want different models

Memory tells you how big you can go. The best local LLM for coding also depends on which of three jobs you’re hiring it for, and the winner is different each time.

For inline autocomplete, the kind that finishes your line as you type, latency beats intelligence. You want a small, fast model that supports fill-in-the-middle, the trick that lets it see the code on both sides of your cursor instead of only what came before. Codestral is built for exactly this; its own description calls out completing partial code with a fill-in-the-middle mechanism. A small Qwen2.5-Coder works well here too. Point your editor’s completion plugin at a 7B or smaller model and you’ll barely notice the round trip.

For a chat window you paste code into and ask questions, mid-sized models earn their keep. This is where 14B to 32B shines: enough reasoning to explain a bug or sketch a function, small enough to answer in seconds. Qwen2.5-Coder 14B and Qwen3-Coder 30B are both comfortable in this role.

For agents, the models that read a repository, plan an edit, and change several files, you want something trained for the workflow. Devstral is built as an agentic model for software engineering, and Mistral reports it scores 46.8% on SWE-bench Verified, a benchmark of real GitHub issues. Qwen3-Coder is trained the same way, with execution-driven reinforcement learning aimed at making its code actually run. If you’re wiring one of these into a local coding agent, our home AI agent setup guide covers the plumbing.

What the size and context numbers actually buy

Two numbers on every model page decide more than the benchmark scores: the quantization and the context length.

Quantization is compression. Q4_K_M, the default I’ve quoted throughout, is a 4-bit format that shrinks a model to roughly a quarter of its full-precision size while keeping most of its quality. It’s the standard sweet spot for local coding. Go lower and mistakes start creeping in; go higher, to 8-bit or full precision, and the download balloons for a difference most people can’t feel on everyday tasks. llama.cpp supports everything from about 1.5-bit up to 8-bit if you want to experiment.

Context length is how much code the model can hold in its head at once. Qwen2.5-Coder and Codestral top out at 32K tokens, which is fine for a file or two. DeepSeek-Coder-V2 16B stretches to 160K, Devstral to 128K, and Qwen3-Coder to 256K, enough to load a small repository into a single prompt. Big context is what makes whole-project work possible, but it isn’t free: the longer the context, the more memory the model needs on top of its base size, which is why that couple of gigabytes of headroom matters.

Why the best keeps moving, and why that is fine

If you came here hoping I’d crown one model and end the argument, I won’t, because the answer changes every few weeks. New open coding models land constantly, and the leader on any given benchmark in July can be mid-table by autumn. Marrying one model is the mistake. Pulling a new one is a single command, and swapping it into your editor takes a minute, so treat your choice as this month’s default, not a lifelong commitment.

The reason to run any of them locally is the part that doesn’t change. Your code never leaves your machine, which matters if you work on anything under NDA or just dislike pasting a proprietary codebase into someone else’s server. You pay nothing per token, so you can let autocomplete run all day. And it works on a plane. If you want the full walkthrough of getting a model running, our guide to running an LLM locally covers install to first answer, and if you’re shopping for hardware to do it well, the Beelink GTR9 Pro is the kind of mini PC that holds a 30B model without complaint.

My honest recommendation is to start smaller than you think you need. Most people reach for the biggest model their machine can technically load and then wonder why autocomplete feels sluggish. A 7B model you barely notice will do more for your day than a 30B model you sit and wait on.

FAQ

What is the best local LLM for coding on a laptop?

On a typical 16GB laptop, Qwen2.5-Coder 14B is the best local LLM for coding for most people: it fits at 9.0GB, handles chat and edits well, and leaves room to actually work. On a lighter 8GB machine, drop to the 7B version at 4.7GB.

How much RAM do I need to run a local coding model?

8GB is the realistic floor and runs a 7B model. 16GB is the comfortable middle and opens up 14B-class models. 24GB of video memory or 32GB of system memory lets you run 30B models like Qwen3-Coder. Budget the model’s download size plus two to three gigabytes for the context.

Is a local coding model as good as a cloud model like Copilot?

For autocomplete, explaining code, and routine edits, a good local model is close enough that you won’t miss the cloud. For sprawling reasoning across a large codebase, frontier cloud models still lead. Plenty of developers run both: local for the constant small stuff, cloud for the occasional hard problem.

Which local model is best for autocomplete in an editor?

Codestral, because it’s built around fill-in-the-middle completion, or a small Qwen2.5-Coder if you want something lighter. Both are fast enough to suggest code as you type without a noticeable lag.

Do I need an NVIDIA GPU?

No. These models run on CPU and system RAM through Ollama or llama.cpp, and they run especially well on Apple Silicon Macs, which share memory between the CPU and GPU. A discrete NVIDIA card mostly buys you speed and the ability to hold a larger model in fast video memory.

The Short Version

The best local LLM for coding is the largest capable model your memory can hold for the job you’re doing. On 8GB, run Qwen2.5-Coder 7B. On 16GB, step up to the 14B version or DeepSeek-Coder-V2 16B. With a 24GB card or a 32GB laptop, Qwen3-Coder 30B and Devstral 24B are the ones to try. Use a small fast model for autocomplete, a mid-sized one for chat, and an agent-trained model like Devstral for editing files. Stick with Q4_K_M, keep a couple of gigabytes free for context, and don’t overthink the choice, because next month there will be a new default anyway. The point isn’t the leaderboard. It’s that your code stays on your machine and costs nothing to run.