Discuss Scratch
- Discussion Forums
- » Advanced Topics
- » SB2 Validator
- nXIII
-
1000+ posts
SB2 Validator
SB2 Validator
A web app to help debug tools that output Scratch files. Get it here.
It currently supports .sb2 project files and .json project info files (support for sprite files is forthcoming). Drag and drop files anywhere onto the page or click to select a file from your computer. The validator will show “Valid” if the file conforms to the most recent Scratch file format, or show “Failed!” with error details if the file does not conform.
Note: The validator is very strict. Even if a file can be read by Scratch, it may not validate—files must closely match Scratch's own format, and include most of the information that Scratch includes in its own project files. This is to establish a minimum set of properties that programs can expect to see in Scratch files.
Extensions
The validator does not allow arbitrary properties in project.json files that Scratch does not use. However, it does allow extension properties beginning with x_. This helps other programs include additional information and metadata in a project file while avoiding future name conflicts with Scratch's properties. For example:
Browser Support
It works on the stable branches of Chrome, Firefox, and Safari. I only test Chrome regularly, so let me know if it stops working in any of those browsers.
Bugs
It has 'em. Please report any bugs you find on this thread, with (1) a link to a project which exhibits this bug and (2) a short description of the bug. See the bottom of this post for a list of known bugs.
Source Code
SB2 Validator is written in CoffeeScript. You can get the source (and license) on the Github repo.
Specification
There's no specification for the Scratch project file format, but SB2 Validator is written in a declarative style so it's easy to understand the format of project files. The declaration of window.schema (search for “@schema = ” in validate/index.coffee) is a readable description of the objects and types in the file format.
A web app to help debug tools that output Scratch files. Get it here.
It currently supports .sb2 project files and .json project info files (support for sprite files is forthcoming). Drag and drop files anywhere onto the page or click to select a file from your computer. The validator will show “Valid” if the file conforms to the most recent Scratch file format, or show “Failed!” with error details if the file does not conform.
Note: The validator is very strict. Even if a file can be read by Scratch, it may not validate—files must closely match Scratch's own format, and include most of the information that Scratch includes in its own project files. This is to establish a minimum set of properties that programs can expect to see in Scratch files.
Extensions
The validator does not allow arbitrary properties in project.json files that Scratch does not use. However, it does allow extension properties beginning with x_. This helps other programs include additional information and metadata in a project file while avoiding future name conflicts with Scratch's properties. For example:
{ // ... "info": { "hasCloudData": false, "videoOn": false, // ... "x_generator": "Awesome Scratch Compiler", "x_version": "2.1", "x_projectProperties": { "language": "JavaScript" } } }
Browser Support
It works on the stable branches of Chrome, Firefox, and Safari. I only test Chrome regularly, so let me know if it stops working in any of those browsers.
Bugs
It has 'em. Please report any bugs you find on this thread, with (1) a link to a project which exhibits this bug and (2) a short description of the bug. See the bottom of this post for a list of known bugs.
Source Code
SB2 Validator is written in CoffeeScript. You can get the source (and license) on the Github repo.
Specification
There's no specification for the Scratch project file format, but SB2 Validator is written in a declarative style so it's easy to understand the format of project files. The declaration of window.schema (search for “@schema = ” in validate/index.coffee) is a readable description of the objects and types in the file format.
Last edited by nXIII (Dec. 19, 2013 22:02:00)
- blob8108
-
1000+ posts
SB2 Validator
Dropbox lied to me! Cool, thanks. That link is broken, but I tested it with a different project.
- nXIII
-
1000+ posts
SB2 Validator
Updated the list of menu names (removed some obsolete ones).
- nXIII
-
1000+ posts
SB2 Validator
SB2 validator is now on Github! It has a nicer, shorter URL too: http://nathan.github.io/sb2/validate/
- drmcw
-
1000+ posts
SB2 Validator
Error messages are somewhat unfriendly;
Failed!
Expected (one of at “scripts 0.2.2.1”) or undefined at “scripts”
?
Failed!
Expected (one of at “scripts 0.2.2.1”) or undefined at “scripts”

- nXIII
-
1000+ posts
SB2 Validator
The things in quotes show the key path and the things in brackets show the valid options. Could you share the project file that you were trying to validate? Error messages are somewhat unfriendly;
Failed!
Expected (one of [all, this script, other scripts in sprite] at “scripts 0.2.2.1”) or undefined at “scripts”
- drmcw
-
1000+ posts
SB2 Validator
The things in quotes show the key path and the things in brackets show the valid options. Could you share the project file that you were trying to validate? Error messages are somewhat unfriendly;
Failed!
Expected (one of [all, this script, other scripts in sprite] at “scripts 0.2.2.1”) or undefined at “scripts”
It was Griffpatch's Scratchnapped project!
Because I was pretty sure it would fail

Last edited by drmcw (Dec. 19, 2013 22:32:52)
- nXIII
-
1000+ posts
SB2 Validator
Scratchnapped project!Thanks for reporting that bug! I also found and fixed another one using the same project, and it now validates for me. It was Griffpatch's
- drmcw
-
1000+ posts
SB2 Validator
No problem. The reason I expected the validator to fail and still do for Scrathnapped is because in the monster sprite, on the when I receive Head Pound 2, in change variable yyy by chgY. the chgY looks like a parameter but it's not in a define block. Surely that should flag an error?
- nXIII
-
1000+ posts
SB2 Validator
Yeah—I'm not doing a lot of semantic checking on the scripts right now, but that would be a useful error to throw. No problem. The reason I expected the validator to fail and still do for Scrathnapped is because in the monster sprite, on the when I receive Head Pound 2, in change variable yyy by chgY. the chgY looks like a parameter but it's not in a define block. Surely that should flag an error?
- k9lego
-
1000+ posts
SB2 Validator
What's wrong with the ability to make changes (variable lists, etc.) to custom blocks?
k9lego

- nXIII
-
1000+ posts
SB2 Validator
Sorry, I'm not sure I understand what you're asking. What's wrong with the ability to make changes (variable lists, etc.) to custom blocks?
- drmcw
-
1000+ posts
SB2 Validator
One of the features I like in scratch is the ability to create those.Sorry, I'm not sure I understand what you're asking. What's wrong with the ability to make changes (variable lists, etc.) to custom blocks?k9lego.
Did anyone say it was wrong? If you think that was what was in scratchnapped then it isn't. It is in fact a bug. See this for an example.
Last edited by drmcw (Dec. 28, 2013 09:48:22)
- AxNoodle
-
2 posts
SB2 Validator
The validator says:
Expected (((_mouse_at“childeren.0.scripts.0.2.1.1”)or(sprite name at “childeren.0.scripts.0.2.1.1”)at“childeren.0.scripts.0.2.1.1”)or undefined at“childeren.0.scripts”) or (string at “childeren.0.target”)or (string at“childeren.0.listName”)at“childeren.0”
What is wrong?
Expected (((_mouse_at“childeren.0.scripts.0.2.1.1”)or(sprite name at “childeren.0.scripts.0.2.1.1”)at“childeren.0.scripts.0.2.1.1”)or undefined at“childeren.0.scripts”) or (string at “childeren.0.target”)or (string at“childeren.0.listName”)at“childeren.0”
What is wrong?
- HenWiii
-
13 posts
SB2 Validator
The validator says:
Expected string at “objName”
Can you tell me what went wrong?
Here's the sb2: Waluigi pinball v2.0.sb2
Expected string at “objName”
Can you tell me what went wrong?
Here's the sb2: Waluigi pinball v2.0.sb2
- Discussion Forums
- » Advanced Topics
-
» SB2 Validator