Blocking Image Input in Claude Code for Non-Vision Models
If you use Claude Code with a model that cannot see images — like GLM-5.2 or DeepSeek-V4 through Ollama — pictures can cause problems. The model cannot understand them, so a pasted screenshot becomes garbled text, and every attempt wastes time and confuses the conversation.
This guide shows you, step by step, how to stop Claude Code from reading images. You do not need to be a developer to follow along. Each step tells you what to do, why it matters, and how to check it worked.
What you need before you start
- Claude Code installed and working on your computer.
- A text-only model such as GLM-5.2 or DeepSeek-V4, available through Ollama.
- A text editor — any editor works, because you will create one small file.
Everything in this guide happens in one file called .claude/settings.json. You create it once, and it applies every time you use Claude Code in that project.
Step 1: Create the settings file
Open your project folder and create a new folder called .claude. Inside it, create a file called settings.json. If the folder or file already exists, open the file instead.
This file is where Claude Code reads its rules. It is a plain text file, so any text editor works.
Step 2: Block local image files
Claude Code reads files with a tool called Read and writes files with Write and Edit. You can tell it to refuse all three for image files. Copy the text below into your settings.json and save:
{
"permissions": {
"deny": [
"Read(*.png)", "Read(*.jpg)", "Read(*.jpeg)",
"Read(*.gif)", "Read(*.webp)", "Read(*.bmp)", "Read(*.svg)",
"Write(*.png)", "Write(*.jpg)", "Write(*.jpeg)",
"Write(*.gif)", "Write(*.webp)", "Write(*.bmp)", "Write(*.svg)",
"Edit(*.png)", "Edit(*.jpg)", "Edit(*.jpeg)",
"Edit(*.gif)", "Edit(*.webp)", "Edit(*.bmp)", "Edit(*.svg)"
]
}
}
Why this works: the list covers the common image formats — PNG, JPG, GIF, WebP, BMP, and SVG. The rules take effect immediately, so Claude Code will no longer read, create, or change image files in this project.
Step 3: Block web images
Images can also arrive from the internet through a tool called WebFetch. Permission rules cannot block a web address directly, so this step uses a small hook — a rule that runs before the tool is used. Add the text below to your settings.json, after the closing brace of the first block, and save:
{
"hooks": {
"PreToolUse": [
{
"matcher": "WebFetch",
"hooks": [
{
"type": "command",
"command": "input=$(cat); url=$(echo \"$input\" | jq -r '.tool_input.url // empty'); if echo \"$url\" | grep -qiE '\\.(png|jpe?g|gif|webp|bmp|svg)([?#]|$)'; then echo '{\"hookSpecificOutput\":{\"hookEventName\":\"PreToolUse\",\"permissionDecision\":\"deny\",\"permissionDecisionReason\":\"Web image fetch blocked\"}}'; fi"
}
]
}
]
}
}
Why this works: the hook looks at every web address Claude Code tries to open. If the address ends in an image format, the request is stopped before anything is downloaded.
Step 4: Block pasted images
Pasted images are part of your message, so they are the hardest to block. A second hook can reject a message that contains an image path. Add this to your settings.json and save:
{
"hooks": {
"UserPromptSubmit": [
{
"hooks": [
{
"type": "command",
"command": "jq -r '.prompt // empty' | grep -qiE '\\.(png|jpe?g|gif|webp|bmp|svg)([?#]|$)' && exit 2 || true"
}
]
}
]
}
}
Why this works: when you send a message, the hook checks it for image file names. If it finds one, the whole message is stopped. This is a strict rule — it cannot remove just the image, so the entire message is rejected.
Step 5: Restart Claude Code
Permission rules from Step 2 work right away, but the hooks from Steps 3 and 4 only load when a session starts. To make them active, close Claude Code and open it again.
How to check: after restarting, try to open a web image. If the hook is working, the request is blocked. If it still opens, the settings file may not have loaded — check that the file is named exactly settings.json and lives inside the .claude folder.
Step 6: Launch with your non-vision model
Now start Claude Code with the model you want. Open your terminal and type one of these:
claude --model glm-5.2:cloud
claude --model deepseek-v4-flash:0731-cloud
You can also set a default model in settings.json with the "model" field, so every session starts with the model you prefer.
What to keep in mind
- Bypass mode overrides everything. The
bypassPermissionsmode (Shift+Tab) ignores these rules. They are a helpful guardrail, not a lock. - Pasted images are all-or-nothing. The prompt hook rejects the whole message, not just the image.
- Watch for false positives. The prompt hook also blocks a message if you simply type an image file name, like "image.png".
- These rules are per project. They apply to the folder where the
.claudefolder lives. Other projects are unaffected.
Summary
Claude Code cannot switch off vision with a single button, but you can block every route images use to reach the model. Create a settings.json file, add the deny rules and two hooks, restart, and launch with your non-vision model. The result is a cleaner, more predictable assistant that never wastes time on images it cannot see.