Figma to Theme.json
WordPress plugin to access Figma variables in a format compatible with theme.json. Written with Claude Sonnet 4.5.
by Your Name · github.com/bengoshow/figma-to-theme-json · website
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/bengoshow/figma-to-theme-json/archive/refs/heads/main.zipA WordPress plugin that fetches design variables from Figma and converts them to WordPress theme.json compatible format.
Features
- 🎨 Fetch design variables directly from Figma files
- 🔄 Automatic conversion to theme.json custom settings format
- 📋 Copy to clipboard functionality
- 💾 Download as JSON file
- 🎯 Support for colors, spacing, typography, and more
- 🔗 Handles variable aliases/references
Installation
- Upload the
figma-to-theme-jsonfolder to/wp-content/plugins/ - Activate the plugin through the 'Plugins' menu in WordPress
- Navigate to 'Figma Variables' in the WordPress admin menu
Configuration
1. Get Your Figma Access Token
- Go to Figma Account Settings
- Scroll to "Personal access tokens"
- Click "Generate new token"
- Give it a name and copy the token (starts with
figd_)
2. Get Your Figma File Key
Your Figma file key is in the URL:
https://www.figma.com/design/[FILE_KEY]/[FILE_NAME]
For example, if your URL is:
https://www.figma.com/design/abc123def456/My-Design-System
Your file key is: abc123def456
3. Configure the Plugin
- Go to Figma Variables in your WordPress admin
- Enter your Figma Access Token
- Enter your Figma File Key
- Click Save Settings
Usage
Fetch Variables
- Click Fetch Variables from Figma
- Wait for the plugin to retrieve and transform your variables
- View the results in the theme.json Format tab
Export Options
- Copy to Clipboard: Click to copy the JSON to your clipboard
- Download JSON: Download the formatted JSON as a file
Add to Your Theme
- Copy the JSON output from the plugin
- Open your theme's
theme.jsonfile - Add or merge the custom settings:
{
"version": 2,
"settings": {
"custom": {
// Paste your Figma variables here
}
}
}
Use Variables in Your Theme
Variables are accessible as CSS custom properties:
Figma Variable: color/primary/500
CSS Variable: var(--wp--custom--color--primary--500)
Example:
.my-element {
background-color: var(--wp--custom--color--primary--500);
padding: var(--wp--custom--spacing--medium);
}
Variable Naming Conventions
The plugin converts Figma variable names to kebab-case and creates nested structures:
| Figma Variable Name | theme.json Path | CSS Variable |
|---|---|---|
color/primary |
color.primary |
--wp--custom--color--primary |
spacing/small |
spacing.small |
--wp--custom--spacing--small |
typography/body-line-height |
typography.body-line-height |
--wp--custom--typography--body-line-height |
Supported Variable Types
- COLOR: Converted to hex or rgba format
- FLOAT: Converted to pixel values (for spacing) or decimals (for line-height, opacity)
- STRING: Preserved as-is
- BOOLEAN: Converted to true/false
- VARIABLE_ALIAS: Automatically resolved to the referenced value
Requirements
- WordPress 5.8 or higher (for theme.json support)
- PHP 7.4 or higher
- Active internet connection to fetch from Figma API
Troubleshooting
"Figma API Error: Invalid token"
- Verify your access token is correct
- Make sure the token hasn't expired
- Generate a new token if needed
"Figma API Error: File not found"
- Check that your file key is correct
- Ensure you have access to the Figma file
- Verify the file contains variables
No Variables Showing
- Make sure your Figma file has variables defined
- Check that variables are published in Figma
- Try refreshing the page and fetching again
Development
File Structure
figma-to-theme-json/
├── assets/
│ ├── css/
│ │ └── admin.css
│ └── js/
│ └── admin.js
├── includes/
│ ├── class-figma-api.php
│ └── class-theme-json-transformer.php
├── templates/
│ └── admin-page.php
├── figma-to-theme-json.php
└── README.md
Changelog
1.0.0
- Initial release
- Fetch variables from Figma API
- Convert to theme.json format
- Copy and download functionality
- Support for all variable types
License
GPL v2 or later
Support
For issues, questions, or contributions, please visit the plugin repository.