Skip to main content
AI Tool Radar

Best Local LLM for Coding 2026: Models by RAM and Setup

Code Assistants

The best local LLM for coding depends on memory. Qwen3.8-27B leads at 32 GB, with picks for 16 GB and 64 GB, context settings and agent setup.

7 min read2026-11-09Facts verified: 2026-11-09

By Roland Hentschel

This site contains affiliate links. We may earn a commission at no extra cost to you. This helps us keep the site running and continue providing free guides and comparisons.

The Bottom Line#

The best local LLM for coding is the largest model that still leaves room for a big context on your machine. On 32 GB that is Qwen3.8-27B, the newest Apache 2.0 model in the Qwen family, with coding and long agentic tasks as its stated focus. Below that, you trade agent work for autocomplete and single-file help.

These are picks by documented size, license and the vendor's stated purpose, as of 9 November 2026. We have not run our own benchmarks, and the benchmark tables on model cards come from the vendors themselves.

For general use and non-coding workloads, start with the Best Local LLM guide.

What is the best local LLM for coding?#

Qwen3.8-27B is the best starting point if you have 32 GB of RAM or unified memory, Devstral Small 2 if you have 24 GB, and Gemma 4 12B if you have 16 GB. The table shows what each memory size can realistically hold.

Your memoryModelOllama tagDownloadContext limitLicense
16 GBGemma 4 12Bgemma4:12b7.7-8.0 GB256KApache 2.0
16 GBMiMo V2.6 9Bmimo-v2.66.6-8.7 GB256KSee model page
24 GBgpt-oss-20bgpt-oss:20b14 GB128KApache 2.0
24 GBDevstral Small 2devstral-small-215 GB256KApache 2.0
32 GBQwen3.8-27Bqwen3.8:27b18 GB256KApache 2.0
32 GBQwen3.6-27Bqwen3.6:27b18-19 GB256KApache 2.0
32 GBGLM-4.7-Flashglm-4.7-flash19 GB198KMIT
48-64 GBQwen3.6-35B-A3Bqwen3.6:35b-a3b23 GB256KApache 2.0
64 GB and upQwen3-Coder-Nextqwen3-coder-next52 GB256KApache 2.0

Download sizes and context limits are as listed in the Ollama library on 9 November 2026, except Devstral Small 2, where we use the 256K from Mistral's model card and Ollama's page lists 384K. The memory column is our planning estimate from the download size plus headroom for context.

Why these:

  • Qwen3.8-27B is a dense 27B model that Alibaba describes as a step forward in "coding, professional work, research, and long-horizon agentic tasks". It also reads images, which helps with screenshots and design mockups.
  • Devstral Small 2 comes from Mistral with a narrow purpose: "using tools to explore codebases, editing multiple files and power software engineering agents". Mistral says it runs on a single RTX 4090 or a Mac with 32 GB of RAM.
  • Gemma 4 12B is the most capable option that leaves real headroom on a 16 GB machine.
  • Qwen3-Coder-Next has 80B total parameters and 3B active. Its memory need follows the total count, so the small active number does not mean it fits on a laptop.

The largest coding models are out of reach for desktop hardware. Ollama lists devstral-2 at 75 GB and qwen3-coder:480b at 290 GB, and models such as GLM-5.3 and Kimi K3.1 Pro appear in its model list as cloud models.

How much memory does a local coding LLM need?#

Plan for 32 GB if you want an agent, because agents need a large context on top of the weights. A coding agent loads files, tool output and its own conversation history, and all of that takes memory.

Three figures from the vendors set the bar:

  • Ollama says coding tools "should be set to at least 64000 tokens".
  • Qwen advises at least 128K tokens for Qwen3.6 to preserve its thinking capabilities.
  • LM Studio recommends more than about 25K for Claude Code.

Ollama's default is the most common reason a local agent feels broken. Below 24 GiB of VRAM it uses 4K tokens, which is far too little for an agent. Raise it yourself:

OLLAMA_CONTEXT_LENGTH=64000 ollama serve

Then verify with ollama ps. The PROCESSOR column should say 100% GPU. If part of the model has moved to the CPU, the model no longer fits in GPU memory and speed drops, so lower the context or pick a smaller model.

If you run several agents at once, memory grows again. Ollama states that required RAM scales with OLLAMA_NUM_PARALLEL multiplied by OLLAMA_CONTEXT_LENGTH.

How to Connect a Local Model to a Coding Agent#

The fastest route is Ollama, which starts the agent for you:

ollama launch claude
ollama launch codex
ollama launch opencode

Claude Code talks to Ollama through its Anthropic-compatible API. Ollama's integration page says to pick a local model from its tool-capable list and set a context of 64K or more. Use a model marked as tool-capable, because an agent that cannot call tools cannot edit files.

With LM Studio, start its server and point Claude Code at it:

lms server start --port 1234
export ANTHROPIC_BASE_URL=http://localhost:1234
export ANTHROPIC_AUTH_TOKEN=lmstudio
claude --model openai/gpt-oss-20b

Which of the two suits you is covered in Ollama vs LM Studio. Installation from scratch is covered in How to Run an LLM Locally.

On Apple Silicon, two open-source projects from our radar are built for this job: Rapid-MLX is an OpenAI-compatible MLX server for coding agents, and claude-code-local is a proxy for the Claude Code CLI. If you do not know what your machine can handle, whichllm reads your hardware and ranks the models that will run on it.

When a Hosted Coding Tool Is the Better Choice#

A local model is the right call when your code must not leave the machine, when you have no reliable connection, or when you already own the hardware. It is the wrong call when you want the strongest model available for hard refactoring across a large repository.

Hosted tools have fewer memory limits and need no maintenance. If privacy is not the deciding factor, compare Claude Code, Cursor and GitHub Copilot first. You do not have to pick only one: a local model can take the routine and sensitive work while a hosted one handles the hard problems.

FAQ#

Can a local LLM replace Claude Code or Cursor?#

Not one for one. Claude Code can connect to a local model through Ollama or LM Studio, so the agent workflow stays. The limit is the model: a 27B model on your own machine does not have the capability of a hosted frontier model on hard, repository-wide tasks.

What is the best local LLM for coding on 16 GB of RAM?#

Gemma 4 12B at 7.7 to 8.0 GB is the safest choice, because it leaves room for the context. Treat 16 GB as suitable for autocomplete, explanations and single-file work rather than agents with a large context.

Why is my local coding agent so bad at reading my project?#

The most likely cause is the context length. Ollama defaults to 4K tokens below 24 GiB of VRAM, so most of what an agent reads does not fit. Set the context to at least 64K and check ollama ps.

Do I need a GPU for local coding models?#

For agents, in practice yes, or an Apple Silicon machine with enough unified memory. A CPU can run small models, but the speed suits batch work rather than interactive coding.

Which local coding model has the most permissive license?#

Qwen3.8-27B, Devstral Small 2, gpt-oss-20b and Gemma 4 are Apache 2.0, and GLM-4.7-Flash is MIT. Both are permissive licenses, but read the license on the model page before you ship, because it can differ between model versions.


Roland Hentschel

Roland Hentschel

AI & Web Technology Expert

Web developer and AI enthusiast helping businesses navigate the rapidly evolving landscape of AI tools. Testing and comparing tools so you don't have to.

More Code Assistants Guides

Related Reading