Validate theme.json
validate_theme_jsonLint a WordPress block theme's theme.json and style variations for version errors, duplicate slugs, invalid colors, missing font sources, deprecated keys, and WCAG contrast failures. Returns errors and warnings with JSON paths.
Instructions
Lint a block theme's theme.json and its style variations: version, duplicate palette/font-size/spacing/shadow slugs, invalid colour values, font families whose fontFace has no src, customTemplates/templateParts naming templates that do not exist, deprecated v1 keys and blocks, and WCAG contrast of the text/background pairs the styles actually use (root, link, button, headings, blocks and block style variations — resolved through the palette). Returns {valid, errors[], warnings[]} with JSON paths. Checks the active theme by default; pass theme_json to lint a draft file's text before writing it. Reading the raw file (for version and deprecated keys) needs the companion plugin; without it the merged REST data is linted.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| theme | No | Theme stylesheet (directory) whose theme.json to read, e.g. a draft theme id. Defaults to the active theme. Global-styles data and variations are only available for the active theme; other themes need the companion plugin. | |
| site_id | No | Which configured WordPress site to act on. Optional — with a single site configured it is used automatically; with several, the default site is used unless you name one. Run list_sites for valid ids. | |
| theme_json | No | Raw theme.json text to lint instead of reading one from the site — useful before write_theme_file. Template names are still checked against the active theme. | |
| include_variations | No | Also lint each style variation, including the contrast of its palette over the theme's styles. | |
| include_user_styles | No | Also check contrast with the site's Site Editor customisations layered on top (active theme only). |