Devxhub - Layer2JSON is a Figma plugin that exports design layers (text, images, shapes) as structured JSON. This plugin uses TypeScript and NPM to make development easy and streamlined.
To support image uploads, create a POST endpoint that accepts two properties:
uuid
(string)image
(binary data).
In the response, return a url
pointing to the uploaded image. Ensure that the endpoint includes the header Access-Control-Allow-Origin: null
to handle requests from Figma, which sends Origin: null
in the request header.
- Node.js (which includes NPM) – Download Node.js
- TypeScript – Install globally using:
npm install -g typescript
- Figma Plugin Typings – Install in the plugin directory:
npm install --save-dev @figma/plugin-typings
-
Install Node.js and NPM: Node.js includes NPM, which is used to manage dependencies. You can download it here.
-
Install TypeScript: TypeScript allows you to add type annotations, making code easier to manage and debug.
npm install -g typescript
-
Install Figma API Type Definitions: In your plugin directory, run the following command to get the latest Figma Plugin API typings:
npm install --save-dev @figma/plugin-typings
-
Compile TypeScript to JavaScript: You’ll need to compile TypeScript code (
code.ts
) into JavaScript (code.js
) for the plugin to run in Figma.
-
Editor Recommendation: We recommend using Visual Studio Code for development. Download it here: VS Code.
-
Set up TypeScript Compilation:
- Open the plugin directory in Visual Studio Code.
- Start compiling TypeScript by running the following command in VS Code:
- Terminal > Run Build Task...
- Select npm: watch to automatically compile on save.
- Learn more about Figma Plugins: Figma Plugin Quickstart Guide
- Learn more about TypeScript: TypeScript Documentation