Theme JSON Schema


A JSON Schema for theme.json and one for block.json are now available to help with building block based themes. The schema can be used by code editors to provide things like tooltips, autocomplete, and validation while editing theme.json or block.json.

Visual Studio Code and WebStorm are two popular editors that support JSON Schema out of the box, and many other editors can have support added via plugins. Check the documentation for your favorite editor to see how to enable JSON schemas there. SchemaStore.org and JSON Schema have lists of supported editors if you want to try it out and your current editor doesn’t have support.

For Visual Studio Code, all you need to do is add "$schema": "https://schemas.wp.org/trunk/theme.json" to the beginning of your theme.json file.

Adding the schema to theme.json in Visual Studio Code

Validation

Properties that are not a part of the schema will show up with undercurls to help catch typos and improperly nested properties.

Navigating validation problems with the problems view and fixing them in Visual Studio Code

Tooltips

Tooltips describe properties and include the version of WordPress that they were introduced.

Hovering over properties to see tooltips in Visual Studio Code

Autocomplete

Autocomplete can make editing theme.json faster and lead to fewer errors.

Adding a new color to the theme palette using tab to autocomplete in Visual Studio Code

Versioning

Older versions of the schema can be accessed by replacing trunk with the version of Gutenberg that you’d like to use the schema for. For example https://schemas.wp.org/wp/5.8/theme.json for the version of Gutenberg used in WordPress 5.8.

Contributing

The source for the theme.json schema can be found on GitHub at WordPress/gutenberg. Issues an pull requests to the contents of the schema can be made there.

Additionally, the schemas have been added to the SchemaStore catalog which is used by some editors to discover schemas. SchemaStore is not a part of WordPress.org, but issues and pull requests to update the catalog are welcome on GitHub at SchemaStore/schemastore.