Design Tokens Extraction
Extract and normalize design tokens from design files into standardized formats.
Overview
This skill enables extraction of design tokens from Figma, Sketch, and Penpot design files using their respective MCP servers. Extracted tokens are normalized to the W3C Design Tokens Community Group format for platform-agnostic storage and conversion.
This skill covers:
- Connecting to design files via MCP servers (Figma, Sketch, Penpot)
- Extracting color, typography, spacing, and shadow tokens
- Normalizing extracted data to W3C DTCG format
- Converting to platform-specific formats (Swift, CSS, Tailwind)
This skill does NOT cover:
- Design file creation or modification
- Visual design decisions
- Component code generation (see
design-to-swiftui skill)
Quick Reference
MCP Server Tools
| Server |
Tool |
Purpose |
figma |
get_file |
Read Figma file structure |
figma |
get_styles |
Extract published styles |
figma |
get_local_variables |
Extract variables/tokens |
sketch-context |
get_document |
Read Sketch document |
sketch-context |
get_shared_styles |
Extract shared styles |
sketch-context |
get_color_assets |
Extract color variables |
penpot |
get_file |
Read Penpot file |
penpot |
get_components |
List design components |
Token Categories
| Category |
Properties Extracted |
| Color |
hex, rgb, hsl, opacity, description |
| Typography |
family, size, weight, lineHeight, letterSpacing |
| Spacing |
value (px, rem), description |
| Shadow |
color, offsetX, offsetY, blur, spread |
| Border Radius |
value (px, rem) |
| Duration |
value (ms) |
Workflow: Extract Tokens from Design File
Step 1: Connect to Design Source
Determine the design source and use the appropriate MCP server:
Figma:
Use figma MCP server with get_file tool
Input: file_key from Figma URL (e.g., "abc123" from figma.com/file/abc123/...)
Sketch:
Use sketch-context MCP server with get_document tool
Input: file path to .sketch file
Penpot:
Use penpot MCP server with get_file tool
Input: project_id and file_id from Penpot URL
Step 2: Extract Raw Design Data
Query the MCP server for design tokens:
Colors:
- Get published color styles (Figma:
get_styles, Sketch: get_shared_styles)
- Get color variables (Figma:
get_local_variables, Sketch: get_color_assets)
- Extract from component fills if no styles defined
Typography:
- Get text styles from design system
- Extract font family, size, weight, line height, letter spacing
- Map font weights to numeric values (400, 500, 600, etc.)
Spacing:
- Look for spacing tokens in variables/styles
- Extract from auto-layout settings if available
- Check for spacing scale documentation
Shadows:
- Get effect styles (drop shadows, inner shadows)
- Extract color, offset, blur, spread values
Step 3: Normalize to W3C Format
Transform extracted data to W3C Design Tokens structure:
{
"$schema": "https://design-tokens.github.io/community-group/format/",
"color": {
"<category>": {
"<name>": {
"$value": "#hexcode",
"$type": "color",
"$description": "From design file"
}
}
},
"typography": {
"fontFamily": { ... },
"fontSize": { ... },
"fontWeight": { ... }
},
"spacing": { ... },
"shadow": { ... }
}
Step 4: Output in Requested Format
Use the appropriate output style:
design-token-json - W3C DTCG format (default)
design-token-swift - Swift extensions
design-token-css - CSS custom properties
design-token-tailwind - Tailwind config
Extraction Patterns
Figma Color Extraction
When reading from Figma:
Published Styles (preferred):
- Use
get_styles with style_type: "FILL"
- Returns named color styles with descriptions
Variables (Figma variables):
- Use
get_local_variables
- Filter by
resolvedType: "COLOR"
- Group by collection name
Component Fills (fallback):
- Traverse component nodes
- Extract unique fill colors
- Auto-generate names from component path
Sketch Color Extraction
When reading from Sketch:
Shared Styles:
- Use
get_shared_styles with style_type: "layer"
- Extract fill colors from style attributes
Color Assets:
- Use
get_color_assets
- Returns swatch library colors
Document Colors:
- Access document-level color palette
- Often contains brand colors
Penpot Color Extraction
When reading from Penpot:
Color Library:
- Access file's color library
- Returns named colors with metadata
Component Colors:
- Extract from component definitions
- Track color references
Normalization Rules
Color Normalization
| Source Format |
Target Format |
rgba(r, g, b, a) |
#RRGGBBAA |
rgb(r, g, b) |
#RRGGBB |
hsl(h, s%, l%) |
#RRGGBB (converted) |
{ r, g, b } (0-1) |
#RRGGBB (scaled) |
{ r, g, b } (0-255) |
#RRGGBB |
Typography Normalization
| Property |
Source Variations |
Target |
| Font Size |
12px, 0.75rem, 12 |
"0.75rem" or 12 |
| Font Weight |
"bold", 700, "semibold" |
700 (numeric) |
| Line Height |
1.5, 150%, 24px |
1.5 (unitless ratio) |
| Letter Spacing |
0.5px, 0.02em |
"0.02em" |
Naming Normalization
| Source Style |
Target Style |
Example |
color/primary/500 |
color.primary.500 |
Nested groups |
Primary Color |
primaryColor |
camelCase |
primary-color |
primaryColor |
camelCase |
PRIMARY_COLOR |
primaryColor |
camelCase |
Source Metadata
Preserve source information for traceability:
{
"color": {
"primary": {
"$value": "#2196F3",
"$type": "color",
"$extensions": {
"com.figma": {
"variableId": "VariableID:1234",
"styleId": "S:abc123",
"collectionName": "Brand Colors"
}
}
}
}
}
Troubleshooting
No Tokens Found
Symptoms: Extraction returns empty or minimal tokens
Solution:
- Verify design file has published styles (not just local colors)
- Check if using Figma variables vs. older style system
- Look for design system component library
- Try extracting from specific frames/components
Authentication Failed
Symptoms: MCP server returns 401 or access denied
Solution:
- Verify
FIGMA_ACCESS_TOKEN is set for Figma
- Ensure Sketch app is running for sketch-context
- Check Penpot MCP server is running locally
Inconsistent Naming
Symptoms: Token names don't match expected format
Solution:
- Check original design file naming conventions
- Use normalization rules consistently
- Consider mapping file to enforce naming standards
See Also
design-token-json style - W3C format output
design-token-swift style - Swift code output
design-to-swiftui skill - Generate SwiftUI views from tokens
design-system-management skill - Manage token libraries
1---2name: design-tokens-extraction3description: Extract design tokens (colors, typography, spacing, shadows) from Figma, Sketch, and Penpot design files via MCP servers and normalize to W3C format4created: 2026-02-225updated: 2026-02-226tags: [design, tokens, figma, sketch, penpot, w3c]7extends: design-brand-applying-dev8metadata:9 source: https://skillmd.com/skills/arustydev/design-tokens-extraction10---1112# Design Tokens Extraction1314Extract and normalize design tokens from design files into standardized formats.1516## Overview1718This skill enables extraction of design tokens from Figma, Sketch, and Penpot design files using their respective MCP servers. Extracted tokens are normalized to the W3C Design Tokens Community Group format for platform-agnostic storage and conversion.1920**This skill covers:**2122- Connecting to design files via MCP servers (Figma, Sketch, Penpot)23- Extracting color, typography, spacing, and shadow tokens24- Normalizing extracted data to W3C DTCG format25- Converting to platform-specific formats (Swift, CSS, Tailwind)2627**This skill does NOT cover:**2829- Design file creation or modification30- Visual design decisions31- Component code generation (see `design-to-swiftui` skill)3233## Quick Reference3435### MCP Server Tools3637| Server | Tool | Purpose |38|--------|------|---------|39| `figma` | `get_file` | Read Figma file structure |40| `figma` | `get_styles` | Extract published styles |41| `figma` | `get_local_variables` | Extract variables/tokens |42| `sketch-context` | `get_document` | Read Sketch document |43| `sketch-context` | `get_shared_styles` | Extract shared styles |44| `sketch-context` | `get_color_assets` | Extract color variables |45| `penpot` | `get_file` | Read Penpot file |46| `penpot` | `get_components` | List design components |4748### Token Categories4950| Category | Properties Extracted |51|----------|---------------------|52| Color | hex, rgb, hsl, opacity, description |53| Typography | family, size, weight, lineHeight, letterSpacing |54| Spacing | value (px, rem), description |55| Shadow | color, offsetX, offsetY, blur, spread |56| Border Radius | value (px, rem) |57| Duration | value (ms) |5859## Workflow: Extract Tokens from Design File6061### Step 1: Connect to Design Source6263Determine the design source and use the appropriate MCP server:6465**Figma:**6667```text68Use figma MCP server with get_file tool69Input: file_key from Figma URL (e.g., "abc123" from figma.com/file/abc123/...)70```7172**Sketch:**7374```text75Use sketch-context MCP server with get_document tool76Input: file path to .sketch file77```7879**Penpot:**8081```text82Use penpot MCP server with get_file tool83Input: project_id and file_id from Penpot URL84```8586### Step 2: Extract Raw Design Data8788Query the MCP server for design tokens:8990**Colors:**91921. Get published color styles (Figma: `get_styles`, Sketch: `get_shared_styles`)932. Get color variables (Figma: `get_local_variables`, Sketch: `get_color_assets`)943. Extract from component fills if no styles defined9596**Typography:**97981. Get text styles from design system992. Extract font family, size, weight, line height, letter spacing1003. Map font weights to numeric values (400, 500, 600, etc.)101102**Spacing:**1031041. Look for spacing tokens in variables/styles1052. Extract from auto-layout settings if available1063. Check for spacing scale documentation107108**Shadows:**1091101. Get effect styles (drop shadows, inner shadows)1112. Extract color, offset, blur, spread values112113### Step 3: Normalize to W3C Format114115Transform extracted data to W3C Design Tokens structure:116117```json118{119 "$schema": "https://design-tokens.github.io/community-group/format/",120 "color": {121 "<category>": {122 "<name>": {123 "$value": "#hexcode",124 "$type": "color",125 "$description": "From design file"126 }127 }128 },129 "typography": {130 "fontFamily": { ... },131 "fontSize": { ... },132 "fontWeight": { ... }133 },134 "spacing": { ... },135 "shadow": { ... }136}137```138139### Step 4: Output in Requested Format140141Use the appropriate output style:142143- `design-token-json` - W3C DTCG format (default)144- `design-token-swift` - Swift extensions145- `design-token-css` - CSS custom properties146- `design-token-tailwind` - Tailwind config147148## Extraction Patterns149150### Figma Color Extraction151152When reading from Figma:1531541. **Published Styles** (preferred):155 - Use `get_styles` with `style_type: "FILL"`156 - Returns named color styles with descriptions1571582. **Variables** (Figma variables):159 - Use `get_local_variables`160 - Filter by `resolvedType: "COLOR"`161 - Group by collection name1621633. **Component Fills** (fallback):164 - Traverse component nodes165 - Extract unique fill colors166 - Auto-generate names from component path167168### Sketch Color Extraction169170When reading from Sketch:1711721. **Shared Styles**:173 - Use `get_shared_styles` with `style_type: "layer"`174 - Extract fill colors from style attributes1751762. **Color Assets**:177 - Use `get_color_assets`178 - Returns swatch library colors1791803. **Document Colors**:181 - Access document-level color palette182 - Often contains brand colors183184### Penpot Color Extraction185186When reading from Penpot:1871881. **Color Library**:189 - Access file's color library190 - Returns named colors with metadata1911922. **Component Colors**:193 - Extract from component definitions194 - Track color references195196## Normalization Rules197198### Color Normalization199200| Source Format | Target Format |201|---------------|---------------|202| `rgba(r, g, b, a)` | `#RRGGBBAA` |203| `rgb(r, g, b)` | `#RRGGBB` |204| `hsl(h, s%, l%)` | `#RRGGBB` (converted) |205| `{ r, g, b }` (0-1) | `#RRGGBB` (scaled) |206| `{ r, g, b }` (0-255) | `#RRGGBB` |207208### Typography Normalization209210| Property | Source Variations | Target |211|----------|-------------------|--------|212| Font Size | `12px`, `0.75rem`, `12` | `"0.75rem"` or `12` |213| Font Weight | `"bold"`, `700`, `"semibold"` | `700` (numeric) |214| Line Height | `1.5`, `150%`, `24px` | `1.5` (unitless ratio) |215| Letter Spacing | `0.5px`, `0.02em` | `"0.02em"` |216217### Naming Normalization218219| Source Style | Target Style | Example |220|--------------|--------------|---------|221| `color/primary/500` | `color.primary.500` | Nested groups |222| `Primary Color` | `primaryColor` | camelCase |223| `primary-color` | `primaryColor` | camelCase |224| `PRIMARY_COLOR` | `primaryColor` | camelCase |225226## Source Metadata227228Preserve source information for traceability:229230```json231{232 "color": {233 "primary": {234 "$value": "#2196F3",235 "$type": "color",236 "$extensions": {237 "com.figma": {238 "variableId": "VariableID:1234",239 "styleId": "S:abc123",240 "collectionName": "Brand Colors"241 }242 }243 }244 }245}246```247248## Troubleshooting249250### No Tokens Found251252**Symptoms:** Extraction returns empty or minimal tokens253254**Solution:**2552561. Verify design file has published styles (not just local colors)2572. Check if using Figma variables vs. older style system2583. Look for design system component library2594. Try extracting from specific frames/components260261### Authentication Failed262263**Symptoms:** MCP server returns 401 or access denied264265**Solution:**2662671. Verify `FIGMA_ACCESS_TOKEN` is set for Figma2682. Ensure Sketch app is running for sketch-context2693. Check Penpot MCP server is running locally270271### Inconsistent Naming272273**Symptoms:** Token names don't match expected format274275**Solution:**2762771. Check original design file naming conventions2782. Use normalization rules consistently2793. Consider mapping file to enforce naming standards280281## See Also282283- `design-token-json` style - W3C format output284- `design-token-swift` style - Swift code output285- `design-to-swiftui` skill - Generate SwiftUI views from tokens286- `design-system-management` skill - Manage token libraries