theme.json

Global settings and styles configuration for WordPress block themes.

Since: 5.8.0
Current Schema Version: 3
Source: wp-includes/class-wp-theme-json.php

Purpose

theme.json provides a centralized way to:

  • Define design tokens (colors, fonts, spacing)
  • Configure block editor features
  • Apply global styles
  • Control which settings appear in the editor

File Locations

LocationOriginPurpose
wp-includes/theme.jsondefaultWordPress defaults
wp-content/themes/{theme}/theme.jsonthemeTheme configuration
Database (user changes)customUser customizations via Site Editor

Schema Structure

json
{
  "$schema": "https://schemas.wp.org/trunk/theme.json",
  "version": 3,
  "settings": { },
  "styles": { },
  "customTemplates": [ ],
  "templateParts": [ ],
  "patterns": [ ],
  "title": "Theme Name"
}

Data Cascade

Settings and styles merge in order (later overrides earlier):

default → blocks → theme → custom
  1. default — WordPress core defaults
  2. blocks — Block-provided defaults
  3. theme — Theme’s theme.json
  4. custom — User changes via Site Editor

Version History

VersionWordPressChanges
15.8Initial release
25.9Removed custom prefix from settings
36.6Changed spacing size merging behavior

Components

Settings

ComponentDescription
settings-color.mdColor palettes, gradients, duotone
settings-typography.mdFont families, sizes, fluid typography
settings-spacing.mdSpacing scale, padding, margin
settings-layout.mdContent width, wide/full alignment
settings-blocks.mdPer-block setting overrides
settings-other.mdAppearance tools, border, shadow

Styles & Structure

ComponentDescription
styles.mdGlobal and element styles
css-generation.mdHow CSS is generated from theme.json
custom-templates.mdCustom template definitions
template-parts.mdTemplate part areas
patterns.mdPattern registration
schema-overview.mdFull schema reference

Quick Example

json
{
  "$schema": "https://schemas.wp.org/trunk/theme.json",
  "version": 3,
  "settings": {
    "color": {
      "palette": [
        { "slug": "primary", "color": "#0073aa", "name": "Primary" },
        { "slug": "secondary", "color": "#23282d", "name": "Secondary" }
      ]
    },
    "typography": {
      "fontSizes": [
        { "slug": "small", "size": "14px", "name": "Small" },
        { "slug": "medium", "size": "18px", "name": "Medium" }
      ]
    }
  },
  "styles": {
    "color": {
      "background": "var(--wp--preset--color--primary)",
      "text": "#ffffff"
    }
  }
}

CSS Custom Properties

theme.json generates CSS custom properties:

PatternExample
--wp--preset--color--{slug}--wp--preset--color--primary
--wp--preset--font-size--{slug}--wp--preset--font-size--medium
--wp--preset--spacing--{slug}--wp--preset--spacing--20
--wp--preset--gradient--{slug}--wp--preset--gradient--vivid-cyan
--wp--preset--shadow--{slug}--wp--preset--shadow--natural
--wp--custom--{path}--wp--custom--line-height--body