A Figma plugin that exports your designs to structured JSON format with comprehensive node data including styles, layouts, and properties.
Companion: figma2html converts the JSON this plugin produces into HTML with inline styles.
- Complete Node Export: Exports all Figma node types with their properties
- Code Generation: Built-in Figma codegen capabilities
- Structured JSON: Clean, hierarchical JSON output with node relationships
- Style Preservation: Maintains fills, strokes, effects, typography, and layout properties
- Developer-Friendly: TypeScript-based with modern tooling
- Bun runtime
- Figma desktop app or Figma in browser
- TypeScript knowledge for development
- Clone the repository:
git clone <repository-url>
cd figma-export-to-json- Install dependencies:
bun install- Build the plugin:
bun run build- Open Figma
- Go to Plugins → Development → Import plugin from manifest...
- Select the
manifest.jsonfile from this project - The plugin will appear in your Plugins menu
- Open a Figma file with your design
- Go to Plugins → figma-to-json
- Select the node(s) you want to export (you can select multiple nodes)
- Click Export to JSON button in the plugin window
- The JSON will be copied to your clipboard automatically
This plugin also supports Figma's native code generation feature:
- Select any node in your design
- Open the Code panel (right sidebar)
- Choose the plugin from the code generation options
- View the generated JSON output
Note: The plugin works in two modes:
- Plugin UI Mode: Full-featured export with UI controls and error handling
- Code Generation Mode: Quick export through Figma's code panel
If the plugin encounters an error while processing a node:
- Error Display: An error message will appear in the plugin UI
- Copy Error Details: Click "Copy Error Details" to get technical error information
- Copy Node Data: Click "Copy Node Data" to get the problematic node's structure
- Report Issues: Use the copied data to report issues for debugging
This feature helps developers troubleshoot specific nodes that cause crashes and provides detailed debugging information.
# Build the plugin
bun run build
# Watch mode for development
bun run watch
# Lint code
bun run lint
# Fix linting issues
bun run lint:fixfigma-export-to-json/
├── src/
│ ├── code.ts # Main plugin logic
│ ├── altConversion.ts # Advanced node conversion
│ ├── convertNodesOnRectangle.ts # Rectangle conversion utilities
│ ├── helpers.ts # Utility functions
│ ├── altMixins2.ts # Mixin utilities
│ └── figma.d.ts # Figma API type definitions
├── ui.html # Plugin UI
├── manifest.json # Figma plugin manifest
├── package.json # Project configuration
├── tsconfig.json # TypeScript configuration
└── build/ # Compiled output
The exported JSON includes:
- Basic Properties:
id,name,type,width,height - Layout:
layoutMode,layoutAlign,constraints,positioning - Styling:
fills,strokes,effects,opacity,blendMode - Typography:
fontSize,fontName,textAlign,characters(for text nodes) - Border Radius: Individual corner radius values
- Enhanced CSS Variables: Variable names include collection names to avoid conflicts
- Hierarchy: Nested
childrenarray for parent nodes
When Figma variables are used, the exported CSS includes collection names:
{
"cssProps": {
"background-color": "#ff0000",
"background-color-variable": "--theme-primary-color",
"background-color-collection": "Theme Colors",
"background-color-variable-id": "VariableID:123"
}
}This prevents naming conflicts when multiple collections have variables with the same name.
Example output:
{
"id": "123:456",
"name": "Button",
"type": "FRAME",
"width": 120,
"height": 40,
"fills": [...],
"cssProps": {
"background-color": "#007AFF",
"background-color-variable": "--design-system-primary-blue",
"background-color-collection": "Design System"
},
"borderRadius": {
"topLeft": 8,
"topRight": 8,
"bottomRight": 8,
"bottomLeft": 8
},
"children": [...]
}- Runtime: Bun
- Language: TypeScript
- Build Tool: esbuild
- Linting: ESLint with Figma plugin rules
- Dependencies: libx.js, Figma Plugin API
The project uses ESLint with:
- TypeScript support
- Figma plugin-specific rules
- Unused variable checking with underscore prefix ignoring
- Target: ES6
- Bundler: esbuild
- Entry:
src/code.ts - Output:
build/code.js
- Fork the repository
- Create a feature branch:
git checkout -b feature/your-feature - Make your changes
- Run tests and linting:
bun run lint - Commit your changes:
git commit -m 'Add some feature' - Push to the branch:
git push origin feature/your-feature - Submit a pull request
- Follow TypeScript best practices
- Use the existing code style and ESLint configuration
- Test your changes with actual Figma designs
- Update documentation for new features
This project is licensed under the MIT License - see the LICENSE file for details.
If you encounter any issues or have questions:
- Check existing issues in the repository
- Create a new issue with detailed description
- Include steps to reproduce for bugs
- Provide Figma file examples when relevant
- Enhanced CSS variable export: CSS props now include collection info to prevent naming conflicts
- Improved error handling and debug info in code generation and export
- Added support for exporting images and SVGs as PNG in JSON output
- More robust node property extraction and recursive field filtering
- Various code quality and stability improvements
- Initial release
- Basic node export functionality
- Code generation support
- TypeScript implementation with Bun runtime