Building a project from scratch
Project.create() returns a valid, empty project
with a bare stage and nothing else. From there you can assemble a complete .sb3
in code.
A minimal project
Open the result in TurboWarp or the Scratch editor — it will load as a real, editable project.
Checklist for a valid project
- Every sprite needs at least one costume. A costume-less sprite confuses the editor. The stage should have at least one backdrop.
- Set a sensible rotation center on costumes (typically half the image's width and height) so sprites rotate around their middle.
dataFormatmatters for text assets. SVGs are text, so sniffing usually works, but passingdataFormat: 'svg'explicitly is the safe choice when you generate them inline.
Authoring scripts
scratch4js does not include a high-level block-builder. To add scripts, write
into the target's raw blocks object using the Scratch
block format (block ids → block definitions). Generate fresh ids with
uid():
Building large scripts this way is verbose; for that workload consider editing an existing project as a template, or driving the editor through the MCP server.