Theme JSON Schema

A JSONJSON JSON, or JavaScript Object Notation, is a minimal, readable format for structuring data. It is used primarily to transmit data between a server and web application, as an alternative to XML. Schema for theme.json and one for block.json are now available to help with building blockBlock Block is the abstract term used to describe units of markup that, composed together, form the content or layout of a webpage using the WordPress editor. The idea combines concepts of what in the past may have achieved with shortcodes, custom HTML, and embed discovery into a single consistent API and user experience. 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 GutenbergGutenberg The Gutenberg project is the new Editor Interface for WordPress. The editor improves the process and experience of creating new content, making writing rich content much simpler. It uses ‘blocks’ to add richness rather than shortcodes, custom HTML etc. https://wordpress.org/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 GitHubGitHub GitHub is a website that offers online implementation of git repositories that can easily be shared, copied and modified by other developers. Public repositories are free to host, private repositories require a paid subscription. GitHub introduced the concept of the ‘pull request’ where code changes done in branches by contributors can be reviewed and discussed before being merged be the repository owner. https://github.com/ 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.orgWordPress.org The community site where WordPress code is created and shared by the users. This is where you can download the source code for WordPress core, plugins and themes as well as the central location for community conversations and organization. https://wordpress.org/, but issues and pull requests to update the catalog are welcome on GitHub at SchemaStore/schemastore.