Getting started
Install
scratch4js ships ESM, CJS and UMD builds and bundles its only runtime
dependency, @turbowarp/jszip. It requires
Node 18 or newer (or any modern browser).
Your first edit
Load a project from its bytes, change a sprite, and save it back:
Open game.edited.sb3 in TurboWarp or the Scratch
editor to see the changes.
The shape of the API
Almost everything flows through four kinds of object:
Stage and Sprite both extend a shared Target base class, so
costumes, sounds, variables and lists work the same way on either one.
Editing model
Every accessor reads from and writes straight through to the underlying
project.json — there is no separate "commit" step. A Sprite or Costume
instance is a thin, stateless wrapper created on demand: calling
project.sprite('Sprite1') twice gives you two wrappers over the same JSON, so
edits through either are always consistent. Your changes are only persisted to
disk when you call project.save().
Running the examples
The repository ships runnable example scripts that exercise the library against
a bundled example.sb3:
Next steps
- Core concepts — understand the data model.
- Working with sprites & the stage.
- API reference.