Scratch Cheatsheet โ Quick Reference
Scratch 3 block-based programming cheatsheet: variables, lists, clones, broadcasts and the nine block categories โ covers beginners' games, animations and storytelling.
Scratch Scratch 3.0 (online editor)
Scratch 3 (block-based) ยท Event-driven ยท visual ยท cooperatively single-threaded ยท Dynamic (weakly typed variables)
Recommended Learning Path
Build your first program: green flag + Say block โ learn variables, lists and control flow (if / repeat) โ use sensing to read keyboard and mouse, broadcast to make sprites talk โ organize code with custom blocks, do multi-sprite scenes with clones โ finish by skimming the FAQ to dodge pitfalls, and learn the timer for timing and cloud variables for shared high scores.
1.Hello World and the Starting Point
Your first program from the green flag: making a sprite speak, switching costumes and backdrops, and getting to know the nine block categories.
Minimal program
Click the green flag to make the sprite speak โ the starting point of every Scratch project. A minimal program only needs Events and Looks blocks.
Starting with the green flag
The green-flag block is the project's start switch. Clicking the green flag above the stage runs every green-flagged script at once; clicking the red stop button halts them all.
Sprite speaks
The Say and Think blocks make a sprite display text in a speech bubble โ the most direct form of output. With a duration they disappear after the seconds elapse; without one they stay.
Switch costume
Each sprite can have multiple costumes; switching between them creates walking, blinking, etc. The Next Costume block cycles through them in order.
Switch backdrop
Stage backdrops are scenes and can change with the story. Combine with the "when backdrop switches to" block to run different scripts per backdrop.
Nine block categories
Blocks split into nine colored categories: Motion (blue), Looks (purple), Sound (pink), Events (yellow), Control (orange), Sensing (cyan), Operators (green), Variables (orange), My Blocks.
Scripts run top to bottom
Inside a single script blocks run top to bottom โ each finishes before the next starts, so order dictates the sequence of actions.
Save and share
Once you sign in, projects auto-save to the cloud. Use the File menu to download to your computer, or click "Share" in the top-right to publish online for anyone to play.
2.Variables and Constants
Create variables, set and change values, show and hide them, plus cloud variables and local variables.
Create a variable
In the Variables category click "Make a Variable" and type a name (e.g. score). A variable is like a box that can hold numbers, text or booleans.
Set and change
"Set" assigns a value to a variable; "Change" adds or subtracts from the current value. Scores and HP are updated with the Change block.
Show and hide
Variables show by default in the top-left of the stage and you can drag them around. Use the Hide Variable block to clear the screen of ones you don't need.
List variable
A list is a variable that holds many items, like a row of boxes. You can add, delete and read elements at a given index.
Constants and fixed values
Numbers or text you type directly into a block are constants โ they don't change at runtime. Use a variable only when the value needs to vary.
Cloud variable
Cloud variables store data on the server, shared by everyone who opens the project โ perfect for leaderboards, but only numbers are supported.
Local variable
By default variables are shared project-wide. Checking "For this sprite only" makes the variable private to the sprite; each clone then gets its own copy.
Slider variable
Right-click a variable display on the stage to make it a slider โ drag with the mouse to change the value live, handy for volume, speed and other tunable parameters.
3.Data Forms
Scratch data comes in three forms โ numbers, strings and booleans โ and variables auto-infer the type.
Number
Numbers go straight into a block's round white slot โ positive, negative or decimal. The four arithmetic operators all return numbers.
String
Text (strings) fit in the round or oval white slots. Say, Think and list items can all be strings.
Boolean
Comparison and logic blocks return true or false and only fit into the hexagonal slots used for conditionals.
List element
List elements can be numbers or text โ read element n by index. Element types are untyped, so you can mix them.
Automatic type inference
Scratch doesn't require declared types: a variable is whatever you last stored, and you can switch types freely. Numbers and strings auto-convert during operations.
Input format
The Ask block lets the user type; the Answer block returns it as a string. Use an operator block to convert it to a number when needed.
Output format
Say and Think turn data into visible text. Operator results and list elements can be dropped straight into an output block.
Number and text conversion
round rounds to nearest integer; mod gives the remainder. Numbers automatically become text when concatenated.
4.Variables and Data Storage
Store data with variables and lists, and pass data between sprites via clones, broadcasts and cloud variables.
Variable storage
A variable is data's "home": set a value before reading it. Scripts share data by reading and writing the same variable, but mind the timing.
List for multiple items
Lists hold many items at once, like arrays. Read and write by index โ great for logging every score in a round, every enemy's coordinates, etc.
Clones carry data
A clone copies the sprite's entire scripts and variables. Each clone's "For this sprite only" variables are independent โ use an ID to tell clones apart.
Private variable
A "For this sprite only" variable lives independently inside each clone, so changing one doesn't affect the others โ the key to telling clones apart.
Cloud variable
Cloud variables sync numbers to the server so every player shares the same data โ ideal for leaderboards and online battles, but values are numeric only.
Broadcast passes data
Broadcasts carry only a message name; to pass data, write the value into a global variable first, then broadcast and let the receiver read it.
Global vs local variables
By default variables are visible project-wide โ any sprite can read or write them. Choosing "For this sprite only" scopes the variable to that sprite or one of its clones.
Data persistence
Variables only live while the project runs โ refreshing the page or closing the project clears them. Use cloud variables or copy data out for long-term storage.
5.Control Flow
Control script flow with conditionals and loops: if, repeat, repeat-until, wait and stop.
If conditional
"If ... then" only runs the inner blocks when the condition holds. The condition fits in a hexagonal slot โ drop in a comparison or logic block.
If-else
"If ... then ... else" is a two-way branch: when true run the first arm, when false run the second. Great for win/lose or on/off states.
Repeat N times
"Repeat N" loops the inner blocks N times โ handy for step-by-step motion, repeated drawing and playing a sound several times.
Forever loop
"Forever" never stops on its own; combine with the Stop block or a condition to exit. Sprite patrols and scrolling backgrounds belong inside it.
Repeat until
"Repeat until ..." runs the body first, then tests the condition; once true it stops. Handy for waiting on a key press or for a target score.
Wait
"Wait 1 second" pauses the current script; "Wait until" pauses until the condition holds. Note: waits only block the current script โ others keep running.
Stop a script
"Stop all" ends every script; "Stop this script" stops only the current one; "Stop other scripts in sprite" keeps this script running but halts the rest of the sprite.
Combined logic
And, Or and Not combine conditions into one. And needs every piece true, Or needs at least one true, Not flips the result.
6.Custom Blocks (Functions)
Custom blocks wrap repeated code into reusable pieces with parameters and return values โ they are functions.
Make a block
In My Blocks click "Make a new block", give it a name and add parameters โ a Define block appears in the script area for you to fill in the logic.
With parameters
Add number or text inputs when defining a block; supply different values at each call site. Parameters are local variables โ they exist only inside the block.
Return a value
Custom blocks return nothing by default. To get a value back, store it in a variable and read the variable after the call.
Call a custom block
Once defined, drop the call block wherever you need it โ each call runs the block's script once.
Recursion
A custom block can call itself โ that's recursion. Scratch has a stack depth limit, so avoid very deep recursion and prefer loops.
Run without screen refresh
Check "Run without screen refresh" when editing a custom block and it executes in one shot โ perfect for bulk list math and fast calculations.
Parameter locality
Custom block parameters stay local, but variables created inside the block are global by default โ be careful not to collide with an outside variable of the same name.
Reuse and split
After lifting a chunk of logic into a custom block, you can reuse it across events โ scripts become cleaner and easier to debug.
7.Strings
String operations: join, letter-of, length, contains โ supports simple text processing.
Join text
The Join block concatenates two pieces of text into one string โ handy for composing prompts and coordinates.
Letter of
"Letter N of ..." returns the character at position N. Chinese characters each count as one, and so do spaces.
Length of
"Length of ..." returns the character count โ English letters, Chinese characters and spaces each count as one. Useful for empty checks and input length caps.
Contains check
"Contains" checks whether one string contains another and returns a boolean โ use it for keyword detection.
Find position
Combine "Letter N of" and "Length of" to manually search: walk character by character and return the position when matched.
Split into a list
Push each character of a string into a list to handle text character by character. Pair with Repeat for iteration.
Empty string check
"Length = 0" means empty. When the user leaves the input box blank, the answer is an empty string โ check before using it.
Concatenate long text
Scratch's text blocks are single-line; for long output stack several Join blocks. Commas and spaces are preserved as written.
8.Lists and Data Structures
Lists are Scratch's core data structure โ add, delete, read, modify, traverse and simulate two-dimensional data.
Create a list
In the Variables category click "Make a List" โ it appears in the script pane like a variable. Lists on stage can be shown or hidden.
Add and delete
Add appends a new element to the end. Delete removes an entry by index (or delete all). After deletion the trailing indices shift down.
Read an element
"Item N of ..." reads by index starting at 1. Out-of-range indices don't error but return an empty result.
Replace an element
"Replace item N with ..." overwrites the value at that index; length is unchanged โ ideal for updating a single slot.
Insert an element
"Insert ... at N" places a new element at that position; subsequent elements shift right automatically.
Find an element
"... contains ..." tells you whether the list has that element and returns a boolean. Check first to avoid reading empties.
Iterate a list
Use "Repeat until" with an index variable to walk the list โ the typical pattern for simulating iteration.
Simulate 2D data
Lists are one-dimensional, but you can simulate a 2D grid by treating index = row * cols + col โ useful for maps and boards.
9.Project and Resource Management
Manage sprite count, list size and clone limit; optimize performance to avoid lag.
Clone limit
Each project allows at most 300 clones at the same time. Surpassing the limit silently deletes the oldest clones.
List size control
Unbounded lists slow the project down. Delete old data in time, or cap the list at a maximum length.
Sprite count
More sprites mean more work per frame. For many objects of the same kind, prefer clones over duplicate sprites.
Broadcast storm
Broadcasting often (e.g. every frame) restarts every receiver every frame and tanks performance. Only broadcast when something actually changes.
Variable caching
Store the result of repeated calculations in a variable so you don't recompute it. Pre-compute values used in many places.
Sprite list management
The sprite list in the bottom-right of the stage lists every sprite. Drag to reorder; right-click to duplicate, export or delete.
Performance tuning
Reduce per-frame redraws, avoid massive list math, cap clones and particles โ your project becomes smoother.
Costume and sound assets
Every costume and sound is an asset โ the more you have, the bigger and slower to load. Drop unused ones and compress images before importing.
10.Sprites as Objects
Each sprite is an object: it carries its own variables and scripts, and clones are instances of it.
Sprite is an object
A sprite packages costumes, variables and scripts โ it is a small object. The stage acts as a global container.
Clone is an instance
Clones are copy-instances of the sprite. They share costumes and any non-sprite-only scripts, but each has its own position, size and private variables.
Broadcast is a method call
A broadcast is a message sent to other "objects"; the receiver block handles it โ much like a method call in OOP.
Private attribute
A "For this sprite only" variable is a private field of the object. Each clone has its own copy, independent of the others.
Clone reuse
Cloning a sprite gives you the same "template"; tweak the script or variables to derive instances with different behavior โ much like inheritance.
State and behavior
Object state lives in variables; behavior lives in scripts. Branch on a state variable to switch between behaviors.
Event-driven model
Scratch is event-driven: the green flag, keys, clicks and messages each trigger scripts. There's no main function โ execution begins with events.
Message passing
Sprites don't access each other's variables directly; they cooperate via broadcasts plus shared variables โ keeps coupling loose.
11.Debugging and Error Handling
Scratch has no exception mechanism โ find bugs by watching variables, using the Say block, and bounds checks.
No exception mechanism
Scratch doesn't throw โ buggy code just silently misbehaves. Pre-check data and defend against bad values.
Watch a variable
Right-click a variable display on the stage to choose normal read-out, large read-out, slider or hide โ useful for watching values live.
Debug with the Say block
Drop a "say (some variable)" block at a suspicious spot to print intermediate values while you debug โ remove it afterwards.
Bounds check
Before reading a list item, check the index is in range to avoid empties. Valid range is 1 to length.
Empty check
When the answer or a list slot is empty, test first before using it โ otherwise you'll get odd results from arithmetic.
List out of bounds
List indices start at 1, and after deletion the indices shift. Using "length" as the upper bound keeps you in range.
Step-by-step debugging
Break a large script into smaller ones and test each piece, or use Wait blocks to slow it down and watch each step.
Common error checklist
Most bugs come from uninitialized variables, reversed conditions, out-of-range indices or unmatched broadcasts. Walk through the checklist.
12.Input and Output
Read keyboard, mouse and Q&A with sensing blocks; output with say, costumes and backdrops; persist data with cloud variables.
Keyboard input
"Key ... pressed?" detects whether a key is held down. Pair with a loop for continuous motion; pair with a one-shot check for jumping.
Mouse input
Read the mouse pointer position and click state so a sprite can follow the mouse or respond to clicks.
Ask and answer
"Ask ... and wait" pops up an input box; the user's response lands in the Answer block โ always a string.
Touch sensing
Detect whether the sprite is touching the mouse pointer, another sprite or a color โ used for collision and pickup logic.
Sensing value output
x position, y position, direction, loudness, timer โ all readable as sensing values that you can drop straight into operators.
Broadcast output
Broadcasts synchronize actions between sprites โ they're the main inter-sprite output channel, and receivers react.
Cloud variable storage
Cloud variables store numbers on the server so every player shares them โ ideal for high scores and online stats.
On-screen output
Say/Think show text, costume switches show images, play sound outputs audio โ combine them for feedback.
13.Common Pitfalls
The eight pitfalls beginners hit most often โ BAD shows the wrong way, GOOD shows the right way.
Forever loop stuck
Putting a Wait inside a Forever with an unsatisfiable condition freezes the script. Make sure the loop body actually advances the condition.
Broadcast timing
Broadcasts are async โ the sender keeps going immediately while receivers start in parallel. Use "Broadcast and wait" when you need strict ordering.
Clone variable mix-up
Global variables are shared across clones, so changing one changes them all. To tell clones apart, use "For this sprite only" privates.
Wait never satisfied
When "wait until" depends on a condition set by another script, that other script may not be running. Make sure something flips the condition.
Empty value in calculation
An empty answer or list element participates in comparisons and math as false or weird values. Check length first.
List index out of range
List indices start at 1 and max out at length. Using 0 or a too-large index gives nothing and is a common source of bugs.
Costume name mismatch
When switching costumes the name must match the costume panel exactly โ an extra space or missing character and the switch silently fails.
Recursion too deep
Scratch caps recursion depth โ go too deep and the program silently halts or misbehaves. Prefer loops to deep recursion.
14.Multiple Scripts and Concurrency
Multiple event-driven scripts run in parallel; coordinate their order with broadcasts and waits.
Parallel scripts
A single sprite can have several independent scripts that each start from their own event and run in parallel without waiting.
Events are threads
Each event โ green flag, key, click, message โ starts a dedicated script, equivalent to a thread.
Shared variable
All scripts share global variables. When several scripts write the same variable concurrently, updates can clobber each other.
Race condition
Two scripts doing read-modify-write on the same variable can drop updates. Keep critical update sequences inside a single script.
Broadcast sync order
"Broadcast and wait" blocks the sender until every receiver finishes โ useful for sequencing animated acts.
Stop a thread
The Stop block ends targeted scripts: all, this script, or other scripts in this sprite โ handy for reset.
Coordinating sprites
When many sprites move in parallel, use a shared variable plus waits to march them in step or in order.
Single-thread cooperation
Even with parallel scripts, each script still runs blocks one at a time in order. A long loop blocks other scripts of the same sprite.
15.Networking and Extensions
Cloud variables share project data across the network, and extensions add online features like translation and TTS.
Cloud variable networking
Cloud variables sync numbers to the server in real time, so users running the same project share data โ great for leaderboards and simple battles.
Translate extension
The Translate extension calls an online translation service and returns the translated string.
Text to speech
The Text-to-Speech extension reads text aloud with selectable languages and voices โ it needs an online voice service.
Video sensing
The Video Sensing extension uses the webcam to detect motion, so players can control sprites by waving. The first use prompts for camera permission.
Share to the website
Click "Share" in the top-right to publish your project to the Scratch site โ anyone can play, like and comment on it.
Remix
Use the "Remix" button on a project to copy someone else's work and tweak it โ the original author is credited.
Cloud variable limits
Cloud variables are limited: each project gets only so many, values are numeric and short, and rapid updates may be throttled.
Online safety and privacy
Online projects are publicly shared. Don't put your real name, address, phone number or other personal info into them.
16.Time and Timing
Use the timer, wait blocks and days-since-2000 for countdowns, stopwatches and timed levels.
Timer
"Timer" starts counting when the project starts, returns seconds (with decimals) โ the heart of stopwatch and countdowns.
Reset timer
"Reset timer" zeroes the timer โ start a new timing run.
Days since 2000
"Days since 2000" returns the number of days since 2000-01-01 โ useful for cross-day timing or recording "last opened".
Wait seconds
"Wait N seconds" pauses the current script for N seconds โ used for timing, delays and animation frame pacing.
Countdown
Use the timer plus subtraction for a countdown; broadcast the end event when it hits zero.
Stopwatch
Measure an operation's duration with the difference between two timer reads โ great for reaction-time games.
Timed level
Complete the level within a fixed time, or fail. Combine the countdown with the win condition.
Timer-based animation
Drive animations from the timer instead of the frame rate โ so speed stays consistent across machines.
17.Script Lifecycle
Scripts are Scratch's smallest execution unit โ understanding how they start, run and stop is understanding the whole project.
Script as a procedure
A script that starts at an event block and ends at its tail is a small procedure. Many scripts together form the whole program.
Green-flag start
The green flag is the canonical entry point โ clicking it starts every green-flagged script at once, like a main function.
Event handler
An event block is the script's "hat" โ it only runs when triggered. With no hat, a script never starts on its own.
Atomic execution
With "Run without screen refresh" checked, a custom block executes to completion in one go without rendering โ perfect for batch computation.
Parallel lifecycle
Each script starts and stops on its own. The Stop block gives you fine-grained control: all, this script or other scripts in this sprite.
Scope of stop
"Stop this script" affects only the current one; "Stop other scripts in sprite" halts the rest of this sprite's scripts; "Stop all" clears the stage.
State-machine procedure
Use a variable to record the current state and have the script branch on it โ implement menus, gameplay, end screens and the transitions between them.
Project lifecycle
A project goes from asset loading, through a green-flag start, through runtime, to the red stop button, and then save/share โ the full lifecycle.
18.Text Pattern Matching
Scratch has no regex โ use contains, character checks and list splits for simple pattern matching.
No regex
Scratch has no regex blocks. Complex text matching must be hand-built with operator blocks or offloaded to an extension.
Contains match
The "contains" check is the simplest substring match โ does the text contain a given word?
Starts-with check
Read the first character and test it to do a starts-with check โ basic prefix detection.
Ends-with check
Read the last character (index = length) to test the ending โ basic suffix detection.
Character class
To check whether a single character is a digit or letter, make a digit table and query it with "contains".
Pattern search
Scan the text character by character in a loop to find matches โ e.g. extract a run of digits.
Split and parse
Split a text by delimiter into a list and process each piece โ a simple parser.
Wildcard simulation
Combine "contains" with multiple OR branches to simulate wildcards โ e.g. match against a list of keywords.
19.Saving, Publishing and Debugging
Save, export, share projects and debug them โ make your creations smoother and more playable.
Save project
When you're signed in, projects auto-save to the cloud. Use File โ Save to your computer to download a backup.
.sb3 file format
Project files end in .sb3 โ they're a zip containing project.json plus costume, sound and other assets, and they open offline.
Share and publish
Click "Share" in the top-right to publish โ set a title, instructions and tags to help people find it.
Remix and rebuild
Remixing someone else's project is a great learning starting point โ tweak scripts and add levels, then publish your own version.
Debug tools
Locate bugs with variable watchers, the Say block, and slowed-down waits โ verify scripts segment by segment.
Backup and versions
Download .sb3 files locally for backups and rename to keep multiple versions โ if you break something, roll back.
Pre-publish checklist
Before publishing, test every entry point โ green flag, keys, sprite clicks, broadcasts โ and confirm no infinite loops, no out-of-range errors and smooth rendering.
Keep learning
Learn more from the official tutorials, the Scratch Wiki and community projects โ keep iterating on your work.
Official Links
Direct links to the official docs and resources.
About this Cheatsheet
Scratch is a free visual programming language developed by MIT's Media Lab, designed for learners aged 5โ16. It replaces typed code with snap-together blocks: drag Motion, Looks, Sound, Events, Control, Sensing, Operators, Variables and My Blocks into the script area to make sprite animations, interactive games and creative stories. This page is a self-contained Scratch 3 cheatsheet covering roughly 80% of what beginners meet when building games, animations and stories. The 19 chapters each focus on a single topic โ your first program (hello), variables and data storage (vars / types / pointers), control flow (control), custom blocks (funcs), strings and lists (strings / collections), project and asset management (mem), the sprite object model (oop), debugging and common pitfalls (errors / faq), I/O and concurrent scripts (io / threads), cloud variables and extensions (net), time and timing (time), script lifecycle (proc), text pattern matching (regex) and saving/publishing/debugging (build). Each section splits into 8 topics with snippets of 5โ20 lines each, easy to read and copy. Unlike other programming languages, Scratch has no textual syntax โ here the blocks are shown in their readable text form, convenient for offline reference and recall. Everything is rendered locally in your browser โ nothing is uploaded or tracked, and your privacy is safe. This page is part of GuruToolkit's free developer toolset; the snippets here are free to use, with no warranty.
Version 2.1.0