(Redirected from Scratch 2.0 File Format)
|This article has links to websites or programs not trusted by Scratch or hosted by Wikipedia. Remember to stay safe while using the internet, as we cannot guarantee the safety of other websites.|
- This article or section documents the current version of Scratch (version 3.0). For this article in Scratch 2.0, see Scratch File Format (2.0). For this article in Scratch 1.4, see Scratch File Format (1.4).
The Scratch 3.0 file format is the format used to store exported Scratch 3.0 projects and sprites. These are ZIP archives which contain information encoded in a text-based format called JSON and project media in separate files. Projects have the extension
.sb3, and sprites
.sprite3. The MIME type of
.sb3 files is
An .sb3 file is a ZIP archive containing one JSON file,
project.json, representing the project. (On most operating systems, one can extract a
.sb3 file by first renaming it so that it ends with
.zip (settings of the file manager might need to be changed to show file extensions), or one can use a program such as 7-Zip.) Backdrops, costumes, and sounds are stored as individual files with names beginning with their MD5 checksums followed by a file extension.
.Sprite3 files are the same except that the JSON file is named
sprite.json and it represents the sprite as a target.
Projects have the following properties:
- An array of targets, in the same order as in the Scratch User Interface.
- An array of monitors, in their layer order.
- An array of the identifiers of the extensions used. The following values are possible:
- Metadata about the project's author and the Scratch version used.
- True if this is the stage and false otherwise. Defaults to false.
- The name of the sprite. Always "Stage" for the stage. If not provided, the target will not be loaded.
- An object associating IDs with arrays representing variables. The first element of the array is the variable name and the second is the value.
- An object associating IDs with arrays representing lists. The first element of the array is the list name and the second is the list as an array.
- An object associating IDs with broadcast names. Normally only present in the stage.
- An object associating IDs with blocks.
- An object associating IDs with comments.
- The costume number.
- An array of costumes.
- An array of sounds.
- The layer number.
- The volume
The stage has the following properties as well as those of all targets.
- The tempo in BPM.
- Possible values are
"on-flipped". Determines if video is visible on the stage and if it is flipped. Has no effect if the project does not use an extension with video input.
- The video transparency. Defaults to 50. Has no effect if
"off"or if the project does not use an extension with video input.
- The language of the Text to Speech extension. Defaults to the editor language.
Sprites have the following properties as well as those of all targets:
- True if the sprite is visible and false otherwise. Defaults to true.
- The x-coordinate. Defaults to 0.
- The y-coordinate. Defaults to 0.
- The sprite's size as a percentage. Defaults to 100.
- The sprite's direction in degrees clockwise from up. Defaults to 90.
- True if the sprite is draggable and false otherwise. Defaults to false.
- The Rotation Style. Possible values are
Fields are text boxes, drop-down menus, etc. These are used directly in blocks where there is an input into which one cannot drop a reporter. However, more often than not, one should be able to do this; in this case no field exists directly in the block, but an input does, and that input may have a shadow block in it.
A shadow block is a reporter in an input for which one can enter or pick a value, and which cannnot be dragged around but can be replaced by a normal reporter. Scratch internally considers these to be blocks although they are not usually thought of as such. (These notions come from Blockly, which Scratch Blocks is based on.)
Most blocks are represented by objects with the following properties:
- A string naming the block. The opcode of a "core" block may be found in the Scratch source code here or here for shadows, and the opcode of an extension's block may be found in the extension's source code here.
- The ID of the following block or
- If the block is a stack block and is preceded, this is the ID of the preceding block. If the block is the first stack block in a C mouth, this is the ID of the C block. If the block is an input to another block, this is the ID of that other block. Otherwise it is
- An object associating names with arrays representing inputs into which other blocks may be dropped, including C mouths. The first element of each array is 1 if the input is a shadow, 2 if there is no shadow, and 3 if there is a shadow but it is obscured by the input. The second is either the ID of the input or an array representing it as described in the table below. If there is an obscured shadow, the third element is its ID or an array representing it.
- An object associating names with arrays representing fields. The first element of each array is the field's value. For certain fields, such as variable and broadcast dropdown menus, there is also a third element, which is the ID of the field's value.
- True if this is a shadow block and false otherwise.
- False if the block has a parent and true otherwise.
A top-level block object also has the x- and y-coordinates of the block in the code area as
y. A block with a comment attached has a
comment property whose value is the comment's ID. A block with a mutation also has a
mutation property whose value is an object representing the mutation.
|Block||1st element||2nd element||3rd element||4th element||5th element|
|Color||9||"#" followed by a hexadecimal numeral representing the color|
|Broadcast||11||the name||the ID|
||12||"||"||the x-coordinate, if it is top-level||the y-coordinate, if it is top-level|
Mutations are present on blocks where the
opcode property is equal to
custom block ::custom) or
"procedures_prototype" (i.e. the inner part of
define custom block). Mutations have the following properties:
- Always equal to
- Seems to always be an empty array.
- The name of the custom block, including inputs:
%sfor string/number inputs and
%bfor boolean inputs.
- An array of the ids of the arguments; these can also be found in the
inputproperty of the main block.
- An array of the names of the arguments. This is only present when the block has an opcode of
- An array of the defaults of the arguments; for string/number arguments, this is an empty string, and for boolean arguments it is
false. This is only present when the block has an opcode of
- Whether to run the block without screen refresh or not.
Comments have the following properties:
- The ID of the block the comment is attached to.
- The x-coordinate of the comment in the code area.
- The y-coordinate.
- The width.
- The height.
- True if the comment is collapsed and false otherwise.
- The text.
An asset is a costume or sound. (Backdrops are considered costumes.) They have the following properties:
- The MD5 hash of the asset file.
- The name.
- The name of the asset file.
- The name of the format of the asset file.
Costumes have the following properties as well as those of all assets:
- The reciprocal of a costume scaling factor for bitmap costumes. This may be absent. In Scratch 3.0, all bitmap costumes are double-resolution.
- The x-coordinate of the rotation center.
- The y-coordinate of the rotation center.
Sounds have the following properties as well as those of all assets:
- The sampling rate of the sound in Hertz.
- The number of samples.
Monitors have the following properties:
- The ID.
- The name of the monitor's mode: "default", "large", "slider", or "list".
- The opcode of the block the monitor belongs to.
- An object associating names of inputs of the block the monitor belongs to with their values.
- The name of the target the monitor belongs to, if any.
- The value appearing on the monitor.
- The width.
- The height.
- The x-coordinate.
- The y-coordinate.
- True if the monitor is visible and false otherwise.
Monitors that do not belong to lists also have these properties:
- The minimum value of the monitor's slider.
- The maximum value of the monitor's slider.
- True if the monitor's slider allows only integer values and false otherwise.
meta property of project JSON files has the following properties:
- The version of the Scratch VM that the project was created with.
- The user agent of the last person to edit the project.