Scratch 2.0 File Format

From Just Solve the File Format Problem
(Difference between revisions)
Jump to: navigation, search
(Add examples for 2.0)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
{{FormatInfo
 
{{FormatInfo
 
|subcat=Source code
 
|subcat=Source code
|extensions={{ext|sb2}}
+
|extensions={{ext|sb2}}, {{ext|sprite2}}
 
}}
 
}}
 
The '''Scratch 2.0 File Format''' saves projects in version 2.0 of the [[Scratch]] programming language. Scratch is a language designed to teach programming to young children. Since the program code consists of graphical tiles rather than text-based source code, a binary format was used for the earlier [[Scratch 1.4 File Format]], but the format has changed with 2.0. Scratch 2.0 runs from a web browser, so no installation is needed as with the earlier versions. Registered users can save their programs on the server, but unregistered users can still run Scratch online and upload/download programs saved on their own computer.
 
The '''Scratch 2.0 File Format''' saves projects in version 2.0 of the [[Scratch]] programming language. Scratch is a language designed to teach programming to young children. Since the program code consists of graphical tiles rather than text-based source code, a binary format was used for the earlier [[Scratch 1.4 File Format]], but the format has changed with 2.0. Scratch 2.0 runs from a web browser, so no installation is needed as with the earlier versions. Registered users can save their programs on the server, but unregistered users can still run Scratch online and upload/download programs saved on their own computer.
Line 8: Line 8:
  
 
Detailed documentation can be found in the Scratch wiki.
 
Detailed documentation can be found in the Scratch wiki.
 +
 +
== Examples ==
 +
 +
Empty project (via the Scratch wiki):
 +
 +
<pre>
 +
{
 +
"objName": "Stage",
 +
"costumes": [{
 +
"costumeName": "backdrop1",
 +
"baseLayerID": 1,
 +
"baseLayerMD5": "739b5e2a2435f6e1ec2993791b423146.png",
 +
"bitmapResolution": 1,
 +
"rotationCenterX": 240,
 +
"rotationCenterY": 180
 +
}],
 +
"currentCostumeIndex": 0,
 +
"penLayerMD5": "5c81a336fab8be57adc039a8a2b33ca9.png",
 +
"penLayerID": 0,
 +
"tempoBPM": 60,
 +
"videoAlpha": 0.5,
 +
"children": [],
 +
"info": {
 +
"userAgent": "Scratch 2.0 Offline Editor",
 +
"videoOn": false,
 +
"scriptCount": 0,
 +
"flashVersion": "WIN 32,0,0,182",
 +
"spriteCount": 0,
 +
"swfVersion": "v461"
 +
}
 +
}
 +
</pre>
 +
 +
Default project (via the Scratch wiki):
 +
 +
<pre>
 +
{
 +
"objName": "Stage",
 +
"sounds": [{
 +
"soundName": "pop",
 +
"soundID": 1,
 +
"md5": "83a9787d4cb6f3b7632b4ddfebf74367.wav",
 +
"sampleCount": 258,
 +
"rate": 11025,
 +
"format": ""
 +
}],
 +
"costumes": [{
 +
"costumeName": "backdrop1",
 +
"baseLayerID": 3,
 +
"baseLayerMD5": "739b5e2a2435f6e1ec2993791b423146.png",
 +
"bitmapResolution": 1,
 +
"rotationCenterX": 240,
 +
"rotationCenterY": 180
 +
}],
 +
"currentCostumeIndex": 0,
 +
"penLayerMD5": "5c81a336fab8be57adc039a8a2b33ca9.png",
 +
"penLayerID": 0,
 +
"tempoBPM": 60,
 +
"videoAlpha": 0.5,
 +
"children": [{
 +
"objName": "Sprite1",
 +
"sounds": [{
 +
"soundName": "meow",
 +
"soundID": 0,
 +
"md5": "83c36d806dc92327b9e7049a565c6bff.wav",
 +
"sampleCount": 18688,
 +
"rate": 22050,
 +
"format": ""
 +
}],
 +
"costumes": [{
 +
"costumeName": "costume1",
 +
"baseLayerID": 1,
 +
"baseLayerMD5": "f9a1c175dbe2e5dee472858dd30d16bb.svg",
 +
"bitmapResolution": 1,
 +
"rotationCenterX": 47,
 +
"rotationCenterY": 55
 +
},
 +
{
 +
"costumeName": "costume2",
 +
"baseLayerID": 2,
 +
"baseLayerMD5": "6e8bd9ae68fdb02b7e1e3df656a75635.svg",
 +
"bitmapResolution": 1,
 +
"rotationCenterX": 47,
 +
"rotationCenterY": 55
 +
}],
 +
"currentCostumeIndex": 0,
 +
"scratchX": 0,
 +
"scratchY": 0,
 +
"scale": 1,
 +
"direction": 90,
 +
"rotationStyle": "normal",
 +
"isDraggable": false,
 +
"indexInLibrary": 1,
 +
"visible": true,
 +
"spriteInfo": {
 +
}
 +
}],
 +
"info": {
 +
"userAgent": "Scratch 2.0 Offline Editor",
 +
"videoOn": false,
 +
"scriptCount": 0,
 +
"flashVersion": "WIN 32,0,0,182",
 +
"spriteCount": 1,
 +
"swfVersion": "v461"
 +
}
 +
}
 +
</pre>
  
 
== Documentation ==
 
== Documentation ==
* [http://wiki.scratch.mit.edu/wiki/Scratch_File_Format_%282.0%29 Scratch 2.0 File Format]
+
* [https://en.scratch-wiki.info/wiki/Scratch_File_Format_(2.0) Scratch 2.0 File Format]
  
 
== Other links ==
 
== Other links ==
 
* [http://scratch.mit.edu/ Official Scratch site]
 
* [http://scratch.mit.edu/ Official Scratch site]
 +
 +
== Other versions ==
 +
 +
* [https://en.scratch-wiki.info/wiki/Scratch_File_Format_(1.4) Scratch 1.4 File Format]
 +
* [https://en.scratch-wiki.info/wiki/Scratch_File_Format_(3.0) Scratch 3.0 File Format]
  
 
[[Category:ZIP based file formats]]
 
[[Category:ZIP based file formats]]
 
[[Category:JSON based file formats]]
 
[[Category:JSON based file formats]]
 
[[Category:MIT]]
 
[[Category:MIT]]

Latest revision as of 14:22, 18 April 2025

File Format
Name Scratch 2.0 File Format
Ontology
Extension(s) .sb2, .sprite2

The Scratch 2.0 File Format saves projects in version 2.0 of the Scratch programming language. Scratch is a language designed to teach programming to young children. Since the program code consists of graphical tiles rather than text-based source code, a binary format was used for the earlier Scratch 1.4 File Format, but the format has changed with 2.0. Scratch 2.0 runs from a web browser, so no installation is needed as with the earlier versions. Registered users can save their programs on the server, but unregistered users can still run Scratch online and upload/download programs saved on their own computer.

Scratch projects are stored in files with a .sb2 extension. The contents are ZIP-compressed data, including various items which are part of the project (.png, .svg, and .wav files, named with numbers). The main item is a file called project.json, in JSON format.

Detailed documentation can be found in the Scratch wiki.

Contents

 [hide

[edit] Examples

Empty project (via the Scratch wiki):

{
	"objName": "Stage",
	"costumes": [{
			"costumeName": "backdrop1",
			"baseLayerID": 1,
			"baseLayerMD5": "739b5e2a2435f6e1ec2993791b423146.png",
			"bitmapResolution": 1,
			"rotationCenterX": 240,
			"rotationCenterY": 180
		}],
	"currentCostumeIndex": 0,
	"penLayerMD5": "5c81a336fab8be57adc039a8a2b33ca9.png",
	"penLayerID": 0,
	"tempoBPM": 60,
	"videoAlpha": 0.5,
	"children": [],
	"info": {
		"userAgent": "Scratch 2.0 Offline Editor",
		"videoOn": false,
		"scriptCount": 0,
		"flashVersion": "WIN 32,0,0,182",
		"spriteCount": 0,
		"swfVersion": "v461"
	}
}

Default project (via the Scratch wiki):

{
	"objName": "Stage",
	"sounds": [{
			"soundName": "pop",
			"soundID": 1,
			"md5": "83a9787d4cb6f3b7632b4ddfebf74367.wav",
			"sampleCount": 258,
			"rate": 11025,
			"format": ""
		}],
	"costumes": [{
			"costumeName": "backdrop1",
			"baseLayerID": 3,
			"baseLayerMD5": "739b5e2a2435f6e1ec2993791b423146.png",
			"bitmapResolution": 1,
			"rotationCenterX": 240,
			"rotationCenterY": 180
		}],
	"currentCostumeIndex": 0,
	"penLayerMD5": "5c81a336fab8be57adc039a8a2b33ca9.png",
	"penLayerID": 0,
	"tempoBPM": 60,
	"videoAlpha": 0.5,
	"children": [{
			"objName": "Sprite1",
			"sounds": [{
					"soundName": "meow",
					"soundID": 0,
					"md5": "83c36d806dc92327b9e7049a565c6bff.wav",
					"sampleCount": 18688,
					"rate": 22050,
					"format": ""
				}],
			"costumes": [{
					"costumeName": "costume1",
					"baseLayerID": 1,
					"baseLayerMD5": "f9a1c175dbe2e5dee472858dd30d16bb.svg",
					"bitmapResolution": 1,
					"rotationCenterX": 47,
					"rotationCenterY": 55
				},
				{
					"costumeName": "costume2",
					"baseLayerID": 2,
					"baseLayerMD5": "6e8bd9ae68fdb02b7e1e3df656a75635.svg",
					"bitmapResolution": 1,
					"rotationCenterX": 47,
					"rotationCenterY": 55
				}],
			"currentCostumeIndex": 0,
			"scratchX": 0,
			"scratchY": 0,
			"scale": 1,
			"direction": 90,
			"rotationStyle": "normal",
			"isDraggable": false,
			"indexInLibrary": 1,
			"visible": true,
			"spriteInfo": {
			}
		}],
	"info": {
		"userAgent": "Scratch 2.0 Offline Editor",
		"videoOn": false,
		"scriptCount": 0,
		"flashVersion": "WIN 32,0,0,182",
		"spriteCount": 1,
		"swfVersion": "v461"
	}
}

[edit] Documentation

[edit] Other links

[edit] Other versions

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox