A compiler CLI that converts FUSE (a high-level programming language) projects into Scratch 3.0 (.sb3) files.
Scratch FUSE Compiler allows you to write Scratch projects using a more expressive, text-based language called FUSE, then compile them into native Scratch projects. This enables better version control, code organization, and programming patterns for Scratch development.
npm install -g @scratch-fuse/fuseOr use directly with npx:
npx @scratch-fuse/fuse <input-file> <output-file>fuse <input-file> <output-file><input-file>: Path to your project configuration file (YAML format)<output-file>: Path where the compiled .sb3 file will be saved
fuse example/project.yaml output.sb3A FUSE project consists of:
- A project configuration file (YAML)
- One or more FUSE script files (.fuse)
- Optional asset files (images, sounds)
The project configuration file is written in YAML and defines your Scratch project structure.
stage: {}
targets:
- name: "My Sprite"
entry: "./sprite.fuse"# Optional: Import type definitions
types:
- "./types.fuse"
# Optional: Scratch extensions to use
extensions:
- "pen"
- "music"
# Stage configuration
stage:
currentBackdrop: 0
tempo: 60
volume: 100
# Optional: Stage backdrops
backdrops:
- path: "./backdrop1.svg"
name: "Backdrop 1"
x: 240 # rotation center X
y: 180 # rotation center Y
# Optional: Stage sounds
sounds:
- path: "./sound.wav"
name: "My Sound"
# Optional: Stage script
entry: "./stage.fuse"
# Sprite configurations
targets:
- name: "Sprite1"
currentCostume: 0
rotationStyle: "all around" # or "left-right", "don't rotate"
layerOrder: 1
visible: true
x: 0
y: 0
size: 100
direction: 90
draggable: false
tempo: 60
volume: 100
# Optional: Sprite costumes
costumes:
- path: "./costume1.svg"
name: "Costume 1"
x: 48 # rotation center X
y: 50 # rotation center Y
# Optional: Sprite sounds
sounds:
- path: "./meow.wav"
name: "Meow"
# Sprite script
entry: "./sprite1.fuse"| Property | Type | Required | Description |
|---|---|---|---|
types |
string[] |
No | Paths to type definition files |
extensions |
string[] |
No | Scratch extensions to enable |
stage |
object |
Yes | Stage configuration |
targets |
object[] |
Yes | Array of sprite configurations |
| Property | Type | Required | Default | Description |
|---|---|---|---|---|
currentBackdrop |
number |
No | 0 | Index of initial backdrop |
tempo |
number |
No | 60 | Initial tempo (BPM) |
volume |
number |
No | 100 | Initial volume (0-100) |
backdrops |
object[] |
No | - | Stage backdrops |
sounds |
object[] |
No | - | Stage sounds |
entry |
string |
No | - | Path to stage script file |
| Property | Type | Required | Default | Description |
|---|---|---|---|---|
name |
string |
Yes | - | Sprite name |
currentCostume |
number |
No | 0 | Index of initial costume |
rotationStyle |
string |
No | "all around" | Rotation style |
layerOrder |
number |
No | auto | Layer order (higher = front) |
visible |
boolean |
No | true | Initial visibility |
x |
number |
No | 0 | Initial X position |
y |
number |
No | 0 | Initial Y position |
size |
number |
No | 100 | Initial size percentage |
direction |
number |
No | 90 | Initial direction (degrees) |
draggable |
boolean |
No | false | Can be dragged in player |
tempo |
number |
No | 60 | Sprite-specific tempo |
volume |
number |
No | 100 | Sprite-specific volume |
costumes |
object[] |
No | - | Sprite costumes |
sounds |
object[] |
No | - | Sprite sounds |
entry |
string |
No | - | Path to sprite script file |
Backdrop/Costume:
| Property | Type | Required | Description |
|---|---|---|---|
path |
string |
Yes | Path to image file (SVG, PNG, etc.) |
name |
string |
Yes | Asset name in Scratch |
x |
number |
No | Rotation center X coordinate |
y |
number |
No | Rotation center Y coordinate |
Sound:
| Property | Type | Required | Description |
|---|---|---|---|
path |
string |
Yes | Path to sound file (WAV, MP3, etc.) |
name |
string |
Yes | Sound name in Scratch |
FUSE is a C-like language that compiles to Scratch blocks. See the example files for syntax reference.
// Variables
global score = 0
global playerX = 0
// Functions
@export("start game") fn startGame() once -> void {
score = 0
playerX = 0
looks.say("Game Started!")
}
// Event handlers
event.start {
startGame()
}
event.whenKeyPressed("space") {
score = score + 1
}
- Variables:
globaland local variables - Functions: Define reusable code blocks
- Export decorator:
@export("name")creates custom Scratch blocks - Event handlers:
event.start,event.whenKeyPressed(), etc. - Control flow:
if,while,forloops - Built-in namespaces:
looks,motion,sensing,operators, etc.
The example/ directory contains a working example:
project.yaml- Project configurationsort.fuse- Bubble sort implementation for performance testing
To compile the example:
fuse example/project.yaml example/output.sb3All paths in the project configuration file can be:
- Relative paths: Resolved relative to the project configuration file's directory
- Absolute paths: Used as-is
- Images: SVG, PNG, JPG, etc.
- Sounds: WAV, MP3, etc.
- If no costumes/backdrops are provided, an empty transparent SVG is automatically created
The compiler generates a standard Scratch 3.0 (.sb3) file that can be:
- Opened in Scratch 3.0 editor
- Opened in TurboWarp
- Shared on the Scratch website
This compiler depends on several packages in the Scratch FUSE ecosystem:
@scratch-fuse/core- Lexer and parser for FUSE language@scratch-fuse/compiler- Compiler logic@scratch-fuse/serializer- Scratch project serialization@scratch-fuse/builtins- Built-in Scratch block definitions
MPL-2.0
https://github.com/scratch-fuse/fuse
Report bugs at: https://github.com/scratch-fuse/fuse/issues