npm testThis will:
- Create a test HTML page with styled content
- Open it in your browser
- Auto-extract the page to JSON
- Copy JSON to your clipboard
Then just:
- Open Figma
- Run: Plugins → Development → HTML to Figma Converter
- Paste and click "Convert to Figma"
npm run test:sampleCopies the pre-made test-sample.json to your clipboard. Great for quick tests!
- Open any website in your browser
- Open DevTools Console (F12 or Cmd+Option+I)
- Paste the contents of
browser-extract.js - Press Enter
- JSON is auto-copied to clipboard
- Paste into Figma plugin
browser-extract.js- Run in browser console to extract pagetest-automation.js- Auto-generates test page and opens browsertest-sample.json- Pre-made sample for quick testingsrc/code.ts- Main plugin entry pointsrc/converter-new.ts- Orchestrates conversionsrc/converters/html-converter.ts- HTML → Figma conversionsrc/converters/figma-converter.ts- Figma JSON → Figma conversion
# Build the plugin
npm run build
# Watch for changes and rebuild automatically
npm run watch
# Lint code
npm run lint
# Auto-fix linting issues
npm run lint:fix
# Run auto-test
npm test
# Copy sample JSON to clipboard
npm run test:sample- Make code changes in
src/ - Build:
npm run build - Test in Figma:
- Run
npm testto generate test page - OR run
npm run test:samplefor quick test - Paste JSON into plugin
- Run
- Verify the import looks correct
- Iterate as needed
- Check browser console for extraction errors
- Verify the JSON has
position.absolute.width/heightfor all nodes - Check that
stylesobject exists
- Verify the JSON node has a
textproperty - Check that
fontSizeis present in styles - Make sure fonts are available (defaults to Inter)
- Check the
position.absolutecoordinates - Verify width/height are numbers not "0px"
- Look at browser console during extraction
- Check Figma DevTools console
- Verify JSON structure matches expected format
- Test with
test-sample.jsonfirst
{
"type": "CANVAS",
"name": "Page Name",
"children": [
{
"type": "div",
"text": "Optional text content",
"styles": {
"backgroundColor": "rgb(255, 255, 255)",
"fontSize": "16px",
"fontFamily": "Inter, sans-serif",
"color": "rgb(0, 0, 0)"
},
"position": {
"absolute": {
"x": 0,
"y": 0,
"width": 100,
"height": 50
}
},
"children": []
}
]
}{
"type": "FRAME",
"name": "My Frame",
"absoluteBoundingBox": {
"x": 0,
"y": 0,
"width": 100,
"height": 100
},
"fills": [
{
"type": "SOLID",
"color": { "r": 1, "g": 1, "b": 1 }
}
],
"children": []
}- ✅ Lint: 0 errors
- ✅ Build: Successful (34.6 KiB)
- ✅ TypeScript: Compiles correctly
⚠️ 2 VS Code display warnings (false positives - code works fine)
- ✅ HTML-style JSON import
- ✅ Figma-style JSON import
- ✅ Text nodes with fonts and styling
- ✅ Frames with backgrounds and borders
- ✅ Image placeholders
- ✅ Nested layouts
- ✅ Position and sizing
- ✅ Colors (RGB and hex)
- ✅ Shadows and effects
- ✅ Auto-layout (flexbox)
- Default font is Inter (built into Figma)
- Images create placeholder rectangles (can't load external images in plugin)
- Browser-extract auto-copies JSON to clipboard
- Test page auto-extracts after 1 second
- VS Code may show 2 type errors - these don't affect compilation
- Check the JSON structure matches expected format
- Test with
test-sample.jsonfirst - Look at Figma plugin console for errors
- Verify build succeeded:
npm run build - Check that all required properties are present
Happy Testing! 🎨