Skip to main content


How to write snapblocks

Snapblocks is written how you see it in Snap!, with each block on a new line.

when flag clicked
move (10) steps
say [Hello world!]

There are of course different block shapes that you can use.


You can set more shapes with overrides

hat :: hat
cap :: cap

However there are some blocks that will automatically become that shape.

when flag clicked
stop [all V]

Anything after :: is used to define properties about the block, such as it's shape, and more.


C-shapes are created using curly braces.

if <> {

} @addInput

Anything inside the curly braces are placed in the c-shape.

if <> {
move (10) steps
} @addInput


As you probably noticed, there are inputs inside blocks, these are:

number (5)
string [strng]
boolean <>

Number Input

A number input is created by using parentheses (). A number input can only have number in it.

number (5)

String Input

A string input is created by using square brackets []. A string input can have any text in it.

say [Hello world!]

Dropdowns can be created by putting a v right before the closing bracket in inputs. There are 2 types of dropdowns, editable v, and read-only V.

editable bumber (5 v)
editable string [string v]
read-only (5 V)
read-only [string V]

Number dropdowns can have anything in it.

(item (last v) of @list)

Color Input

Color inputs are created by putting a color code inside a string or number input. A color code can either by a hex color code, or an rgb value.

<touching [#911a44] ?>
<touching [rgb(145,26,68)] ?>
<touching (#911a44) ?>

Currently, as of snapblocks 1.4.0, an rgb color cannot be used inside number inputs.

Boolean Input

A Boolean input is created by using angled brackets <>.

Boolean <>

A Boolean input can only have some specific values, which are used to choose whether the input is true or false.

true <t>
false <f>

However, you can also use the static (bigger) Boolean input.

true <true>
false <false>

If you create a predicate with only a Boolean input that is either a static true or false, it will automatically be set to the Boolean block in Snap!



Upvars are created by putting another set of parentheses around a variable, like so.

script variables ((upvar)) @addInput


Categories are automatically set for blocks that are in Snap!, or Scratch. However, you can manually set the category for any block. To set the category, put the category name after ::.

motion :: motion
looks :: looks
sound :: sound
pen :: pen
control :: control
sensing :: sensing
operators :: operators
variables :: variables
lists :: lists
other :: other

This is not an exhaustive list of all the Categories available in snapblocks, but it's the main Categories used in Snap!

It is also possible to create custom colors, by using either a hex color code, or an rgb color code.

custom :: #3a5f75
custom :: rgb(255, 100, 50)


Icons are created by putting either a @ sign, or a $ sign before the icon name.

pause all @pause
pause all $pause

list of icons

Here's a list of all available icons.


There are rings in Snap!, so it's possible to create rings in snapblocks.

({} @addInput)
(() @addInput)
(<> @addInput)

You can put any block inside the first input, as long as it fits the shape.

({move (10) steps} @addInput)
((x position) @addInput)
(<shown?> @addInput)

Now, since rings can contain scripts of multiple blocks, it's very much possible to do that here.

({move (10) steps
say [Hello!]} @addInput)

Rings can also have input names

({} input names: ((#1)) ((#2)) @delInput @addInput)

Define block

Custom blocks are an essential part of Snap!, formerly known as BYOB, Build Your Own Blocks.

Snap! block prototype

The Snap! block prototype (or some might say, define block) is created as such.

{+ custom + block +} :: define

The plus signs are optional, but are what Snap! has by default. If you don't want to type in the plus signs manually, you can use :: define+ instead.

{+ custom + block +} :: define+

When you define a block, you can use any shape or category, and the block will be automatically detected if used later (except it won't set the shape).

<predicate :: motion> :: define+


Custom blocks can have inputs, which can be added by adding upvars, the same way that they are shown in Snap!

{block ((string)) ((number #)) ((boolean ?)) ((default = hi)) :: looks} :: define+

block [string] (5) <> [hi]

You can also set inputs using their input syntax.

{block [string] (number) <boolean> :: looks} :: define+

block [string] (5) <>

Scratch define

The Scratch define block can be created by typing the word define then the custom block withing curly brackets.

define {custom block [string] (number) <boolean>}

custom block [] () <>

Multiline blocks

Snap! allows for placing newlines in blocks, which can be created like so.

In a command block, you have to either place a backslash \ before a newline, or use \n.

multiline \
block \n cool

Reporters and predicates are easier, because you can just hit enter.


However, you cannot put multiple inputs vertically on the same line, like in the block.

Multiline input

As you may know, you can create a multiline input in Snap! Thankfully it's similar to creating multiline reporters and predicates.

multiline [multiline

Make sure not to indent multiline inputs, as all spaces are shown within an input.


Comments can be added on blocks or by itself, by typing // and then the comment text.

// Comment
block // comment