| name | figma-bridge-html-export |
| description | Transform Figma designs into LLM-friendly HTML/CSS for AI-assisted development |
| triggers | ["convert figma design to html","export figma to semantic html css","generate code from figma design","setup figma bridge server","preview figma design in browser","extract design tokens from figma","create html from figma component","parse figma layout to css"] |
Figma Bridge HTML Export
Skill by ara.so — Design Skills collection.
Overview
Figma Bridge is a Figma-to-code conversion tool that parses Figma designs into clean, semantic HTML/CSS optimized for Large Language Models. It enables AI to accurately understand design intent and achieve pixel-perfect implementation. The tool includes a Figma plugin, local server with live preview, and a standalone conversion pipeline.
Installation
git clone https://github.com/kingkongshot/Figma-Bridge.git
cd Figma-Bridge
npm install
npm run dev
The server starts at http://localhost:7788 by default.
Figma Plugin Setup
- Open Figma and navigate to any canvas
- Right-click on a blank area
- Select Plugins → Development → Import plugin from manifest
- Select the
manifest.json file from the project root
- Open the plugin via Plugins → Development → Bridge
- Click any component in Figma to see the preview in your browser
Key Components
Server & Preview
The local server provides real-time preview with visual debugging overlays:
npm run dev
PORT=8080 npm run dev
Access the preview interface at http://localhost:7788 (or your custom port).
Bridge Pipeline
The core conversion package is available at packages/bridge-pipeline/:
import { convertFigmaNode } from './packages/bridge-pipeline';
const result = convertFigmaNode(figmaNodeData, {
enableFontMatching: true,
preserveLayout: true
});
console.log(result.html);
console.log(result.css);
Output Files
Generated files are saved to output/:
output/
├── index.html # Main HTML file
├── styles.css # Generated CSS
└── assets/ # Extracted images/fonts
Configuration
Debug Mode
Enable detailed logging and intermediate output:
BRIDGE_DEBUG=1 npm run dev
Debug files are saved to debug/ directory with timestamped conversion steps.
Font Handling
Figma Bridge automatically matches fonts with Google Fonts:
const config = {
enableFontMatching: true,
fallbackFonts: ['Arial', 'sans-serif']
};
Code Examples
Basic Figma Node Processing
figma.on('selectionchange', () => {
const selection = figma.currentPage.selection;
if (selection.length > 0) {
const node = selection[0];
const nodeData = {
id: node.id,
name: node.name,
type: node.type,
x: node.x,
y: node.y,
width: node.width,
height: node.height,
fills: node.fills,
strokes: node.strokes,
children: node.children?.map(child => processChild(child))
};
fetch('http://localhost:7788/convert', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(nodeData)
});
}
});
Server-Side Conversion
import express from 'express';
import { convertToHTML } from './converter';
const app = express();
app.use(express.json());
app.post('/convert', async (req, res) => {
try {
const figmaData = req.body;
const result = await convertToHTML(figmaData, {
outputDir: './output',
includeDebugOverlay: true
});
res.json({
success: true,
html: result.html,
css: result.css,
preview: `http://localhost:7788/preview/${result.id}`
});
} catch (error) {
res.status(500).json({ error: error.message });
}
});
const PORT = process.env.PORT || 7788;
app.listen(PORT, () => {
console.();
});
Custom Style Processing
function processFills(fills: Paint[]): string {
if (!fills || fills.length === 0) return 'transparent';
const fill = fills[0];
if (fill.type === 'SOLID') {
const { r, g, b } = fill.color;
const a = fill.opacity ?? 1;
return `rgba(${Math.round(r * 255)}, ${Math.round(g * 255)}, ${Math.round(b * 255)}, ${a})`;
}
if (fill.type === 'GRADIENT_LINEAR') {
const stops = fill.gradientStops.map(stop => {
const { r, g, b } = stop.color;
return `rgba(${Math.round(r * 255)}, ${Math.round(g * 255)}, ${Math.round(b * 255)}, )`;
}).();
;
}
;
}
Layout Extraction
function extractLayout(node: SceneNode): CSSProperties {
return {
position: 'absolute',
left: `${node.x}px`,
top: `${node.y}px`,
width: `${node.width}px`,
height: `${node.height}px`,
...(node.layoutMode !== 'NONE' && {
display: 'flex',
flexDirection: node.layoutMode === 'HORIZONTAL' ? 'row' : 'column',
gap: `${node.itemSpacing}px`,
padding: `${node.paddingTop}px ${node.paddingRight}px ${node.paddingBottom}px ${node.paddingLeft}px`
}),
...(node.cornerRadius && {
borderRadius: `${node.cornerRadius}px`
})
};
}
Common Patterns
AI-Assisted Workflow
const designData = await fetchFromFigmaBridge('http://localhost:7788/latest');
const prompt = `
Convert this Figma design to React components:
${JSON.stringify(designData.html)}
${JSON.stringify(designData.css)}
Requirements:
- Use Tailwind CSS
- Make it responsive
- Add proper TypeScript types
`;
Batch Processing
const components = figma.currentPage.findAll(node =>
node.type === 'COMPONENT'
);
for (const component of components) {
const result = await convertToHTML(component, {
outputFile: `output/${component.name}.html`
});
console.log(`Converted: ${component.name}`);
}
Custom Preview Templates
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Figma Bridge Preview</title>
<link rel="stylesheet" href="/styles.css">
<style>
body { margin: 0; padding: 20px; }
.debug-overlay { border: 1px dashed red; }
</style>
</head>
<body>
<div id="root">
</div>
</body>
</html>
Troubleshooting
Plugin Not Loading
cat manifest.json
Server Connection Issues
lsof -i :7788
kill -9 <PID>
PORT=8080 npm run dev
Font Matching Failures
const config = {
enableFontMatching: true,
customFonts: {
'SF Pro': 'system-ui',
'Inter': 'Inter, sans-serif'
},
googleFontsAPI: process.env.GOOGLE_FONTS_API_KEY
};
CSS Not Applied Correctly
BRIDGE_DEBUG=1 npm run dev
cat debug/latest.css
grep -r "styles.css" output/
Large File Performance
const config = {
maxDepth: 10,
skipHiddenLayers: true,
minSize: 1,
imageOptimization: {
maxWidth: 2048,
quality: 0.85
}
};
Memory Issues
NODE_OPTIONS="--max-old-space-size=4096" npm run dev
API Reference
Core Functions
convertFigmaNode(node: FigmaNode, options?: ConversionOptions): ConversionResult
interface ConversionOptions {
enableFontMatching?: boolean;
preserveLayout?: boolean;
outputDir?: string;
includeDebugOverlay?: boolean;
customFonts?: Record<string, string>;
}
interface ConversionResult {
html: string;
css: string;
assets: string[];
metadata: {
nodeId: string;
timestamp: number;
fonts: string[];
};
}
Project Structure
Figma-Bridge/
├── packages/bridge-pipeline/ # Core conversion logic
├── src/ # Server & CLI
├── public/ # Preview interface
├── code.js # Figma plugin
├── ui.html # Plugin UI
├── output/ # Generated files
└── debug/ # Debug output