[BUG] Image base64 size (8.4 MB) exceeds API limit (5.0 MB). Please resize the image before sending.

Resolved 💬 21 comments Opened Jan 22, 2026 by DineshNarra Closed Apr 13, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

constantly running into the error - Image base64 size (8.4 MB) exceeds API limit (5.0 MB). Please resize the image before sending. ' though the size of the image is less. opening a new window also doesn't fix this.

What Should Happen?

Claude for Vs code asks for screenshot and when i provide one, it throws me an error and gets stuck.

Error Messages/Logs

Steps to Reproduce

<img width="520" height="298" alt="Image" src="https://github.com/user-attachments/assets/f2376597-c979-4181-8e7c-3a594eb7a9b4" />

Claude Model

Other

Is this a regression?

I don't know

Last Working Version

2.1.11

Claude Code Version

2.1.11

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

VS Code integrated terminal

Additional Information

_No response_

View original on GitHub ↗

21 Comments

github-actions[bot] · 5 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/19701
  2. https://github.com/anthropics/claude-code/issues/8039
  3. https://github.com/anthropics/claude-code/issues/2104

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

snap-seo · 5 months ago

This is just a new version of the image bug they had previously. Its consistent yet Anthropic won't fix it. it literally breaks all chats, previously one could compact it and it would work again but I dunno a fix now

reyequis · 5 months ago
This is just a new version of the image bug they had previously. Its consistent yet Anthropic won't fix it. it literally breaks all chats, previously one could compact it and it would work again but I dunno a fix now

See my workaround until it’s fixed.

bracketcoder · 5 months ago

Image base64 size (19.9 MB) exceeds API limit (5.0 MB). Please resize the image before sending. (Same Bug)

DineshNarra · 5 months ago

I just stopped using images entirely unless its a small snippet. Claude losses context with every compact session yet carry forwards the image size. This requires some fundamental fixing at anthropic. Lets wait for their response on this bug. hope it gets resolved soon.

AbuMalik0 · 5 months ago

its frustrating

snap-seo · 5 months ago

Its very fustrating and it got better a little bit in recent updates but its still not worth using multi format, however sometimes it helps trumendously for different work flows.

Maybe if they used a real human instead of claude code to fix it...?

threesixtyat · 5 months ago

same here on latest version. worked fine in the last days but suddenly stopped today

zycko-app · 5 months ago

same

ParkerCai · 5 months ago

Ran into this same bug, please fix it.

netudabbah · 5 months ago

PLEASE SOMEONE FIX THIS ASAP

Enashka · 5 months ago

Same here

sarob · 5 months ago

i have been getting these msg in prompts over the past couple of days

  • Image base64 size (5.0 MB) exceeds API limit (5.0 MB). Please resize the image before sending.
  • prompt is too long
  • they are starting to impact my ability to work as I am regularly losing the conversation history. updating a plan markdown file is a workaround, but it is slowing me down.
  • when I try to report these bugs, the Fin AI Agent regularly hallucinates and tries to get me to use non-existing methods to report bugs, e.g. use /doctor or /bug or /debug within claude code.
  • when I ask for a human to help, I get a boilerplate we will email you and then nothing else. The communication stops. No more chat and no email that anything will happen.
  • I like the claude code tooling, but this is a poor experience with little hope of being repaired.
  • I am posting here as a last ditch option of getting any type of support
anquinn · 5 months ago

I cannot upload any screenshot without receiving the error: "Image base64 size (5.0 MB) exceeds API limit (5.0 MB). Please resize the image before sending."

sarob · 4 months ago

Since losing conversation history was a recurring problem for me, I built a bash dashboard to track all Claude Code operational files (CLAUDE.md, MEMORY.md, conversation logs) across projects. It helps you see what Claude knows per project and clean up old session logs.

Zero dependencies, single script: https://github.com/sarob/claude-ops

HikariKogen · 4 months ago

Fixed the problem : Claude Code Stuck on "Image base64 size exceeds API limit"

What Happened: basically we attached a large image in Claude Code. It got saved into the conversation JSONL file. Now every message fails with the same error because Claude Code re-sends all prior messages (including that image) as context on every API call. Even /compact and /context fail.

How to Fix :

Step 1 : Find your conversation file

Your stuck session ID is visible in the error or window title. The conversation file lives at:

C:\Users\<you>\.claude\projects\<project-hash>\<session-id>.jsonl

~/.claude/projects/<project-hash>/<session-id>.jsonl

Step 2: Back up the file ( I did , you dont have to really )

cp <session-id>.jsonl <session-id>.jsonl.backup

Step 3: Find which line has the oversized image

awk '{print NR, length($0)}' <session-id>.jsonl | sort -k2 -n -r | head -10
The largest line(s) are your culprits.

Step 4: Run this fix script ( convert it in your own lang ) :

import json
import sys
import shutil

if len(sys.argv) < 2:
    print("Usage: python fix.py <session-id>.jsonl")
    sys.exit(1)

input_file = sys.argv[1]
output_file = input_file + ".fixed"
backup_file = input_file + ".backup"
MAX_SIZE = 5 * 1024 * 1024  # 5MB

line_num = 0
fixed = 0

print(f"Processing: {input_file}")
shutil.copy2(input_file, backup_file)
print(f"Backup created: {backup_file}")

with open(input_file, "r", encoding="utf-8") as fin, \
     open(output_file, "w", encoding="utf-8") as fout:
    for line in fin:
        line_num += 1
        stripped = line.rstrip("\n")
        if not stripped:
            fout.write(line)
            continue
        try:
            obj = json.loads(stripped)
            content = obj.get("message", {}).get("content") if "message" in obj else None
            if isinstance(content, list):
                modified = False
                new_content = []
                for i, item in enumerate(content):
                    if (isinstance(item, dict)
                        and item.get("type") == "image"
                        and len(item.get("source", {}).get("data", "")) > MAX_SIZE):
                        size_mb = len(item["source"]["data"]) / (1024 * 1024)
                        print(f"  Line {line_num}: Replacing image[{i}] ({size_mb:.1f}MB)")
                        new_content.append({
                            "type": "text",
                            "text": f"[Image removed: {size_mb:.1f}MB exceeded 5MB limit]"
                        })
                        modified = True
                        fixed += 1
                    else:
                        new_content.append(item)
                if modified:
                    obj["message"]["content"] = new_content
                    fout.write(json.dumps(obj, ensure_ascii=False) + "\n")
                    continue
        except json.JSONDecodeError:
            pass
        fout.write(line)

print(f"\nDone. Processed {line_num} lines, fixed {fixed} image(s).")

if fixed > 0:
    shutil.move(output_file, input_file)
    print(f"Original replaced. Backup at: {backup_file}")
else:
    import os
    os.remove(output_file)
    print("No oversized images found. No changes made.")

Step 5: Replace the original

mv <session-id>.jsonl.fixed <session-id>.jsonl

Step 6: Reopen the session

Close and reopen Claude Code. The session should work again. Run /compact to clean up context.

What This Does
Finds any image in the conversation where the base64 string > 5MB
Replaces only that image with a small text placeholder
All your text, smaller images, tool calls, AI responses, and context stay intact
Nothing else is touched

<img width="850" height="452" alt="Image" src="https://github.com/user-attachments/assets/e3710ab2-65fe-49b1-8231-8118ed05c87f" />

sarob · 4 months ago

Sure, technically your solution may work. However, I am realizing an individual conversation with a model should not be that important. Instead, focus your efforts to add strategy and plans to maintain PLANS.md, global and project CLAUDE.md, MEMORY, and SKILLS.md.

A conversation with the model is nothing more than a hallway discussion with a coworker. May be really useful and impact the project. May also be over caffeinated musings that need to be discarded. If your conversation reaches triple digits, dump it and start over.

~ sean

On Feb 27, 2026, at 09:12, HikariKogen @.***> wrote: HikariKogen left a comment (anthropics/claude-code#20021) <https://github.com/anthropics/claude-code/issues/20021#issuecomment-3974072644> Fixed the problem : Claude Code Stuck on "Image base64 size exceeds API limit" What Happened: basically we attached a large image in Claude Code. It got saved into the conversation JSONL file. Now every message fails with the same error because Claude Code re-sends all prior messages (including that image) as context on every API call. Even /compact and /context fail. How to Fix : Step 1 : Find your conversation file Your stuck session ID is visible in the error or window title. The conversation file lives at: C:\Users\<you>\.claude\projects\<project-hash>\<session-id>.jsonl ~/.claude/projects/<project-hash>/<session-id>.jsonl Step 2: Back up the file ( I did , you dont have to really ) cp .jsonl .jsonl.backup Step 3: Find which line has the oversized image awk '{print NR, length($0)}' .jsonl | sort -k2 -n -r | head -10 The largest line(s) are your culprits. Step 4: Run this fix script ( convert it in your own lang ) : import json import sys import shutil if len(sys.argv) < 2: print("Usage: python fix.py <session-id>.jsonl") sys.exit(1) input_file = sys.argv[1] output_file = input_file + ".fixed" backup_file = input_file + ".backup" MAX_SIZE = 5 1024 1024 # 5MB line_num = 0 fixed = 0 print(f"Processing: {input_file}") shutil.copy2(input_file, backup_file) print(f"Backup created: {backup_file}") with open(input_file, "r", encoding="utf-8") as fin, \ open(output_file, "w", encoding="utf-8") as fout: for line in fin: line_num += 1 stripped = line.rstrip("\n") if not stripped: fout.write(line) continue try: obj = json.loads(stripped) content = obj.get("message", {}).get("content") if "message" in obj else None if isinstance(content, list): modified = False new_content = [] for i, item in enumerate(content): if (isinstance(item, dict) and item.get("type") == "image" and len(item.get("source", {}).get("data", "")) > MAX_SIZE): size_mb = len(item["source"]["data"]) / (1024 * 1024) print(f" Line {line_num}: Replacing image[{i}] ({size_mb:.1f}MB)") new_content.append({ "type": "text", "text": f"[Image removed: {size_mb:.1f}MB exceeded 5MB limit]" }) modified = True fixed += 1 else: new_content.append(item) if modified: obj["message"]["content"] = new_content fout.write(json.dumps(obj, ensure_ascii=False) + "\n") continue except json.JSONDecodeError: pass fout.write(line) print(f"\nDone. Processed {line_num} lines, fixed {fixed} image(s).") if fixed > 0: shutil.move(output_file, input_file) print(f"Original replaced. Backup at: {backup_file}") else: import os os.remove(output_file) print("No oversized images found. No changes made.") Step 5: Replace the original mv .jsonl.fixed .jsonl Step 6: Reopen the session Close and reopen Claude Code. The session should work again. Run /compact to clean up context. What This Does Finds any image in the conversation where the base64 string > 5MB Replaces only that image with a small text placeholder All your text, smaller images, tool calls, AI responses, and context stay intact Nothing else is touched — Reply to this email directly, view it on GitHub <https://github.com/anthropics/claude-code/issues/20021#issuecomment-3974072644>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAJDAOUEZYBQOWZRMFNPTQD4OB3HRAVCNFSM6AAAAACSQJJYRSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTSNZUGA3TENRUGQ>. You are receiving this because you commented.
kurevin · 4 months ago

It is amazing that this is still not fixed....

EDIT: even "fork conversation from here" does not work on borked session.

atikrahmanbd · 4 months ago
# Fixed the problem : Claude Code Stuck on "Image base64 size exceeds API limit" What Happened: basically we attached a large image in Claude Code. It got saved into the conversation JSONL file. Now every message fails with the same error because Claude Code re-sends all prior messages (including that image) as context on every API call. Even /compact and /context fail. How to Fix : # Step 1 : Find your conversation file Your stuck session ID is visible in the error or window title. The conversation file lives at: C:\Users\<you>\.claude\projects\<project-hash>\<session-id>.jsonl ~/.claude/projects/<project-hash>/<session-id>.jsonl # Step 2: Back up the file ( I did , you dont have to really ) cp <session-id>.jsonl <session-id>.jsonl.backup # Step 3: Find which line has the oversized image awk '{print NR, length($0)}' <session-id>.jsonl | sort -k2 -n -r | head -10 The largest line(s) are your culprits. # Step 4: Run this fix script ( convert it in your own lang ) : `` import json import sys import shutil if len(sys.argv) < 2: print("Usage: python fix.py <session-id>.jsonl") sys.exit(1) input_file = sys.argv[1] output_file = input_file + ".fixed" backup_file = input_file + ".backup" MAX_SIZE = 5 * 1024 * 1024 # 5MB line_num = 0 fixed = 0 print(f"Processing: {input_file}") shutil.copy2(input_file, backup_file) print(f"Backup created: {backup_file}") with open(input_file, "r", encoding="utf-8") as fin, \ open(output_file, "w", encoding="utf-8") as fout: for line in fin: line_num += 1 stripped = line.rstrip("\n") if not stripped: fout.write(line) continue try: obj = json.loads(stripped) content = obj.get("message", {}).get("content") if "message" in obj else None if isinstance(content, list): modified = False new_content = [] for i, item in enumerate(content): if (isinstance(item, dict) and item.get("type") == "image" and len(item.get("source", {}).get("data", "")) > MAX_SIZE): size_mb = len(item["source"]["data"]) / (1024 * 1024) print(f" Line {line_num}: Replacing image[{i}] ({size_mb:.1f}MB)") new_content.append({ "type": "text", "text": f"[Image removed: {size_mb:.1f}MB exceeded 5MB limit]" }) modified = True fixed += 1 else: new_content.append(item) if modified: obj["message"]["content"] = new_content fout.write(json.dumps(obj, ensure_ascii=False) + "\n") continue except json.JSONDecodeError: pass fout.write(line) print(f"\nDone. Processed {line_num} lines, fixed {fixed} image(s).") if fixed > 0: shutil.move(output_file, input_file) print(f"Original replaced. Backup at: {backup_file}") else: import os os.remove(output_file) print("No oversized images found. No changes made.") ` # Step 5: Replace the original mv <session-id>.jsonl.fixed <session-id>.jsonl` # Step 6: Reopen the session Close and reopen Claude Code. The session should work again. Run /compact to clean up context. What This Does Finds any image in the conversation where the base64 string > 5MB Replaces only that image with a small text placeholder All your text, smaller images, tool calls, AI responses, and context stay intact Nothing else is touched <img alt="Image" width="850" height="452" src="https://private-user-images.githubusercontent.com/121828840/556083374-e3710ab2-65fe-49b1-8231-8118ed05c87f.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzM1MzI3MDcsIm5iZiI6MTc3MzUzMjQwNywicGF0aCI6Ii8xMjE4Mjg4NDAvNTU2MDgzMzc0LWUzNzEwYWIyLTY1ZmUtNDliMS04MjMxLTgxMThlZDA1Yzg3Zi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjYwMzE0JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI2MDMxNFQyMzUzMjdaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT01NzJkNjM5NWQ4ZWI3YTExYmY1ZjMwYTdjNjgxZDFkZGE0MmNkNDExZTMyYTIzNjc2MWM2NTI5MGMwMzYzN2I3JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.uWBC7mJIgQEqP2KfXbIOfMIqqfI_CWS6VG36tKSAGrU">

Thank you, it worked for me!

github-actions[bot] · 3 months ago

Closing for now — inactive for too long. Please open a new issue if this is still relevant.

github-actions[bot] · 2 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.