A schema for theme.json is now available. The schema can be used by supported code editors to provide things like tooltips, autocomplete, and schema validation while editing a file.
SchemaStore.org lists the following editors as supported, and JSON Schema lists a few more.
- IntelliJ IDEA
- PhpStorm
- PyCharm
- Rider
- RubyMine
- Visual Studio 2013+
- Visual Studio Code
- Visual Studio for Mac
- WebStorm
- JSONBuddy
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. Check the documentation for your favorite editor to see how to enable JSON schemas there.
Properties that are not a part of the schema will show up with undercurls to help catch typos and improperly nested properties.
Tooltips describe properties and include the version of WordPress that they were introduced.
Autocomplete can make editing theme.json faster and lead to fewer errors.
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/v11.9.0/theme.json
for Gutenberg 11.9.0.
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. SchemaStore is not a part of WordPress.org, but issues and pull requests to update the catalog are welcome on GitHub at SchemaStore/schemastore.