Can't share or download png save

A couple of my students have ran into an issue where they cannot download their projects as pngs or create a share link. When they try to create a png MakeCode thinks for a while and then stops the process without saying anything (no error or popup). I looked into the browser counsel when this happened and “RangeError: Invalid string length” error (see images).

Does anyone have any advice on how to resolve this issue?


1 Like

As a further update one of the projects now cannot be opened from the My Projects page saying “Sorry, we could not load this project” and the Edge console has a “Uncaught (in promise) TypeError: Cannot read properties of undefined (reading ‘text’)” error. I assume this project is unrecoverable, but I would like to know if there are any know causes of this to avoid in the future.

Step 1: Backup Everything

Before you touch anything, make a copy of the .mkcd file. Even if it’s broken, we don’t want to lose what’s left.


Step 2: Rename and Unzip

  1. Rename the file from project.mkcdproject.zip.
  2. Unzip it with any zip tool (Windows Explorer, 7-Zip, WinRAR, etc.).

You should see a folder structure with files like:

  • main.ts (your TypeScript/blocks code)
  • project.json (project metadata)
  • assets/ (sprites, tilemaps, images)

Step 3: Inspect project.json

Open project.json in a text editor (VS Code, Notepad++, etc.)

  • Look for huge base64-encoded strings — these are usually embedded images or tiles.
  • If there’s an obvious very large string, that’s likely what’s breaking the PNG/export.

Step 4: Temporarily Remove Problematic Assets

  1. Move large images or tilemaps out of the folder (just somewhere safe).
  2. Save the edited project.json without them.
  3. Zip the folder back up and rename to .mkcd.

This stripped-down project may now open in MakeCode and export as PNG or share link.


Step 5: Recover Code

If main.ts is intact, you can open it and copy all your scripts into a new project.

  • Even if images are gone, the code logic is usually salvageable.
  • Re-import small versions of the assets gradually instead of all at once.

Step 6: Prevent Future Issues

  • Avoid massive inline images — load them via img functions instead of embedding huge base64 data.
  • Break big games into smaller projects.
  • Save .mkcd backups often.
  • Consider exporting backups before major changes.