Skip to main content

Import & Export

This guide covers moving assets between Figma and your code:
  • Icons and SVG: SVG markup, files or a whole icon folder become editable vectors, icon components and variant sets, with their color bound to a token. Re-importing updates the existing icons in place.
  • Images: PNG, JPEG and GIF files become image layers, or the fill of layers you already have.
  • Web pages and HTML: a live site, your localhost dev server or an HTML string becomes editable frames, with auto layout where it reproduces the page and colors, spacing and type bound to your file’s tokens.
  • Export for code: PNG, JPG, SVG and PDF renders of layers, the icon SVGs inside a screen, and the original image files behind image fills, written to a folder in your repo.
Everything runs through the Desktop Bridge plugin you already have. No plugin re-import and no Figma token, except for export links (output: "urls"). Page import in Local Mode uses a Chrome-based browser already installed on your computer.

Before you start

Local Mode starts with the core tools only. The import and export tools are in the assets toolset. Ask your AI assistant to import an icon and it switches the toolset on with:
Or preload it by adding assets to the FIGMA_TOOLSETS environment variable in your MCP config (for example FIGMA_TOOLSETS=assets). figma_import_svg and figma_export_assets can overwrite (component artwork and files), so they can’t run through figma_call. Call them by name. If your client doesn’t refresh its tool list after figma_enable_toolsets, restart the client or set FIGMA_TOOLSETS. figma_import_image only adds layers or replaces fills, and figma_import_html only adds a new import, so both also run through figma_call. Cloud Mode lists every tool from the start. It has no filesystem, so you pass SVG markup and image data inline, and it imports public web pages only (see Local Mode and Cloud Mode).

Icons and SVG

Import one icon

The SVG becomes a frame of editable vector layers on the current page, in clear space next to your existing content. size fits the art inside a 24×24 box, keeping its aspect ratio. width or height fit within one side instead. parentId puts the result inside a frame, section, group, page or slide. In Local Mode, pass paths (absolute paths to .svg files) instead of svgs. Layer names come from svgs[i].name, then the file name, then the SVG’s <title>, then “SVG”. namePrefix: "Icon/" files them in a folder.

Draw an icon or illustration

There is no separate generator. The AI writes the SVG itself and imports it, so nothing costs AI credits and the result can go straight into your icon set:
For an illustration, leave out asComponent and give it room:
SVG that imports cleanly has a viewBox, uses paths instead of <text>, and uses currentColor for the color of a single-color icon. Quality depends on the model’s SVG skill, so check the result with a screenshot and ask for changes.

Icon components

asComponent: true makes each SVG a component (Design files only). Its artwork scales with the instance, so an instance resized to 48×48 draws a 48×48 icon. With size, the component frame is exactly size × size and wide or tall art is centered in it. flatten: true merges an icon into one vector named Vector when all its layers share the same paint and stroke. A flattened icon keeps the same layer structure from one version to the next, so later updates keep instance overrides.

A folder of icons

In Local Mode, point the tool at a folder:
Components land in a section named “Icons” (vectors without components go in an auto-layout frame named “SVG import”; layout.containerName changes the name and an existing section or frame with that name is reused). recursive includes subfolders up to six levels deep. Hidden files, symbolic links inside the folder and nested node_modules folders are skipped. A large folder imports in pages. When the response has remaining.nextOffset, run the same call again with offset set to it. limit sets roughly how many files go in one call; variant sets are never split across pages.

Variant sets from file names

variants.pattern turns file names (or paths relative to directory, without .svg) into component sets. {name} is the set name and each {Axis} becomes a variant property:
axes is optional. It lists the allowed values in display order (the first value is the default variant) and settles ambiguous names. A file that doesn’t match the pattern becomes a standalone component, with a note. Sets are laid out as a variant matrix with Figma’s purple dashed border.

Color and tokens

color recolors the icon:
  • color.variable: a local COLOR variable by name (icon/default or Icons/icon/default) or id.
  • color.variableKey: the key of a COLOR variable in a library the file uses (from figma_get_library_variables). It is imported into the file automatically.
  • color.value: a literal color (hex or any CSS color) instead of a variable.
Figma’s team library sometimes stops answering plugins. When it does, the library check gives up after 15 s and the import fails with an error saying the libraries weren’t checked. Nothing is changed. Local variables and color.value still work. By default (color.apply: "auto") only the paints that were currentColor in the SVG are bound, or every paint when the SVG is a single color. A two-tone icon with a fixed accent keeps its accent. apply: "currentColor" binds only currentColor paints; apply: "all" recolors every solid paint. color.targets limits it to fills or strokes.

Re-importing: updates in place

Re-run the same import after your icons change in code. A component or set with the same name is updated in place by default (onExisting: "update"), so every instance gets the new artwork:
  • Icons whose artwork didn’t change since the last import are reported unchanged and not touched (force: true re-applies them anyway, for example after manual edits in Figma).
  • Where the layer structure is the same, the geometry is swapped in place and instance overrides survive, in this file and in files that use the library. Where it changed, the artwork is replaced and overrides on the old layers reset. keepOverrides: true only updates icons whose structure is unchanged and skips the rest.
  • A component is only updated when it is plain vector artwork: no text layers (unless the SVG had text), no instances, no auto layout, and no component properties other than variants. Anything else that shares the name is reported as a conflict and left alone.
  • The color binding an icon already had carries over.
What you’re asked first. When an icon to update has instances, or its library is published, you are asked before anything changes. The question names the file, how many components and instances, and whether the library is published. You can replace the artwork, update only where instance overrides are kept, or leave existing components alone and import only new icons. A version named “Before SVG import (Figma Console MCP)” is saved to the file’s version history first, so you can restore it. If that version can’t be saved, existing components aren’t changed. Clients that can’t show the question (and Cloud Mode) skip those updates and say why, unless you passed onExisting: "update" yourself. FIGMA_CONSOLE_CONFIRM_DESTRUCTIVE=off turns the question off. onExisting: "skip" leaves existing components alone; "duplicate" creates new ones beside them. matchScope: "page" looks for existing components on the target page only (faster in a big file). Preview first. dryRun: true reports the names, sets, updates, conflicts and the question a real run would ask, without changing Figma.

FigJam and Slides

Both import plain vectors. Components and variant sets are Design-only.
  • FigJam: a batch lands in a section; a single SVG goes on the board at clear space (or inside the section you name with parentId). Binding to variables isn’t available in FigJam (it has no variables), so pass color.value instead of color.variable.
  • Slides: with no parentId the result goes on the focused slide. Pass a slide id as parentId to target another one. Variable binding works.
Dev Mode is read-only, so imports are refused there.

Long imports and interruptions

Big batches are sent to Figma in chunks. In Local Mode, a client that supports MCP Tasks gets a task handle and the import keeps running past the client’s request timeout. If a call stops early (Figma didn’t answer in time, the time budget ran out, or you cancelled), the response has incomplete with a runId and the items not yet sent. Nothing more is sent to Figma in that call. When Figma is idle, run the same call again with resumeRunId: icons that run already imported are recognized instead of imported twice, and components update in place as usual.

What gets removed

Every SVG is treated as untrusted, whoever wrote it. Scripts, event handlers, <foreignObject>, external links and references (hrefs to other files or URLs, url(https://…) in styles), animation elements and editor metadata (Inkscape, Illustrator, Sketch) are removed before Figma sees the markup, and the response counts what was removed. Filters that use effects Figma can’t import are removed whole. SVGs that are malformed, too large (5 MB per SVG), or that expand into too many elements through <use> are reported with the reason and the rest of the batch still imports. See Security. Illustrator and Inkscape exports, <svg:svg> prefixes, <style> class colors, percentage gradients and width="1em" sizes are handled. Figma itself reports some SVGs it can’t read (for example a degenerate gradient); those come back with Figma’s message.

Images

figma_import_image brings PNG, JPEG and GIF images in as layers with an image fill:
  • New layers are rectangles (nodeType: "frame" for frames) at the image’s size. A @2x or @3x file name, or density, places a high-resolution image at 1x.
  • width and height fit new layers; with both, fit: "contain" (default) keeps the aspect ratio and fit: "exact" makes the layer exactly that size.
  • scaleMode (FILL, FIT, CROP, TILE) sets how the image sits in its layer, as in Figma’s fill panel.
  • Several images are laid out in a grid frame named “Images” (a section in FigJam).
Fill existing layers instead of creating new ones:
The image replaces those layers’ fills; they aren’t moved or selected. A detached fill style or replaced fill variable is mentioned in the notes. Limits: 8 MB and 4096 px per side per image. The type is read from the file’s bytes, not its extension. WebP, HEIC, AVIF, BMP, TIFF and SVG aren’t accepted (Figma’s plugin API takes PNG, JPEG and GIF; use figma_import_svg for SVG). Images that can’t be read are reported and the rest still import. dryRun: true checks formats, sizes and targets without changing Figma. For a single image onto layers you already have, figma_set_image_fill (in the inspect toolset) does the same with less to fill in.

Web pages and HTML

figma_import_html renders a page in a real Chrome and rebuilds it in the open Figma Design file as editable layers: frames, real text, images, vectors and effects. Each viewport width becomes one frame, side by side in a new Section.
Preview first. dryRun: true captures and analyzes the page without writing anything to Figma. It reports layer counts, an outline of the container tree, the fonts that would be substituted and how many values match your tokens. Adjust selectors and exclude from the outline, then run the same call without dryRun. The import-web-page skill walks an AI assistant through that loop.

What you need

Local Mode uses a Chrome-based browser already on your computer. Nothing is downloaded and there’s nothing extra to install. It looks for Google Chrome, Chromium, Microsoft Edge and Brave, then Chrome’s Beta, Dev and Canary channels, in the usual places: /Applications and ~/Applications on macOS, Program Files and %LOCALAPPDATA% (per-user installs, including Canary) on Windows (Edge ships with Windows, so it is always found there), and /usr/bin, /opt, your PATH and the Chromium snap on Linux. The search runs the first time you import, not when the server starts.
  • To choose the browser, set FIGMA_HTML_IMPORT_BROWSER (or CHROME_PATH or PUPPETEER_EXECUTABLE_PATH) to its executable. A path that doesn’t exist is an error, never skipped silently.
  • FIGMA_HTML_IMPORT_BROWSER_ARGS adds Chrome switches, for example --lang=de-DE. Switches that would change how the capture browser is controlled or isolated (debugging ports, the profile folder, headless mode, certificate checks, the sandbox, site isolation and web security, file access, extensions, host name mapping) are ignored, with a warning.
  • When no browser is found, the error lists the paths it checked. Install Google Chrome or set FIGMA_HTML_IMPORT_BROWSER.
Cloud Mode renders in Cloudflare Browser Rendering on the server. There’s nothing to install, but it can only load public pages (below). In both modes, the open file must be a Design file. FigJam boards, Slides decks and Dev Mode are refused.

What you can import

file:// roots. Set FIGMA_HTML_IMPORT_FILE_ROOTS to one or more absolute folders (separated by : on macOS and Linux, ; on Windows) and restart the MCP server. A file must be inside one of them, judged by its real path, so .. segments and symbolic links can’t reach outside. Files over 50 MB and network-share paths (file://server/…) are refused. The alternative needs no setting: serve the folder (npx serve ./site) and import http://localhost:3000/….

Viewports, states and parts of a page

  • viewports: 1 to 4 widths per call (240–3840 px, default 1440). height sets the window height, which matters for 100vh sections. Widths under 768 emulate a phone (touch, mobile user agent, meta viewport) unless you pass mobile: false; deviceScaleFactor sets the pixel ratio for responsive images. name labels the frame.
  • colorScheme: "dark" captures the page’s dark mode and matches against your dark token mode.
  • Height: fullPage (default) captures the whole scroll height up to maxHeight (16,000 px by default). For app shells that scroll an inner panel instead of the page, expandScrollContainers: true grows that panel to its full content first.
  • Parts of a page: selectors (up to 20) captures elements as separate frames instead of the whole page, and selectorAll: true captures every match. exclude leaves out chat widgets and banners. Cookie banners and modal overlays are hidden by default (hideOverlays).
  • States: actions runs up to 20 steps before the capture: hover, click, focus, type, press, wait, waitFor and scrollTo. For example [{ type: "click", selector: "[aria-label=Menu]" }] captures an open menu. Typing into password and payment-card fields is always refused.
  • Late content: waitForSelector waits for an element; settleMs adds a pause after load and after actions. javascript: false renders the static HTML and CSS only.
  • Placement: by default the import goes in clear space on the current page. placement.parentId puts the frames inside an existing page, section or frame instead (no new Section is created there).

Auto layout, checked against the page

Every container’s layout is checked before it gets auto layout. The tool reads the CSS (flexbox, CSS grid, stacked blocks, single-line inline rows), simulates Figma’s auto layout for it, and keeps auto layout only if the simulation puts every child where the browser drew it: A container that doesn’t pass keeps its children at their exact positions, as an absolutely positioned frame, so the page still looks right. frames[].layoutFallbacks in the result counts the reasons, and autoLayoutFrames, gridFrames and absoluteFrames show the split. Many fallbacks on a page you want to edit? Try "relaxed". The rest of the page:
  • Text: one text layer per paragraph, with styled ranges, links, native bullet and numbered lists, truncation and line clamps.
  • Visuals: solid, linear, radial and conic backgrounds, images (read from the browser after a scroll pass that loads lazy images), inline SVG as vectors, borders per side, radius per corner, shadows, blur, opacity, blend modes, clipping, and the paint order Chrome used.
  • What Figma can’t represent (canvas, video, cross-origin iframes, native checkboxes, CSS filters) becomes an image layer from a screenshot. rasterizeUnsupported: false leaves placeholders instead.
  • Fonts are matched to the fonts your Figma has, walking the page’s font stack the way a browser does (known aliases such as system-ui included). When nothing in the stack is available, fontFallback (Inter by default) is used. Every substitution is listed in fonts.substitutions. fontMap: [{ from: "Söhne", to: "Inter" }] sets substitutes yourself.
  • Wrapper elements that draw nothing are collapsed (simplify: "safe", or "aggressive" / "none"). maxLayers caps layers per frame (4,000 by default); deeper content beyond it is rasterized.
  • The import is plain frames, not instances of your components. To build a screen from your design system’s components, use figma_resolve_components and figma_instantiate_component, or the generate-with-design-system skill.
verifyFidelity: true exports the result, compares it with the browser’s screenshot and returns a similarity score with the worst-matching regions. includeReferenceScreenshot: true adds the screenshot as a hidden, locked layer for side-by-side review.

Matching your design system

By default (designSystem.mode: "bind"), values that match the file’s local variables and styles are bound to them:
  • colors (fills, strokes, text, shadow colors), spacing (padding, stack gaps and grid row and column gaps), corner radius, stroke widths, opacity, typography (text styles, or font size, family, weight, line height and letter spacing variables) and shadows (effect styles, or shadow variables).
  • A variable is only used where its scopes allow it (a radius token never becomes a gap), semantic tokens that alias others are preferred, and the CSS custom property that produced a value (read from Chrome’s cascade) decides between equal candidates.
  • Colors match within colorTolerance (CIEDE2000 distance, default 1, which is imperceptible); lengths within lengthTolerance (0.5 px by default). Fixed widths and heights are only bound with bindSizes: true.
  • A dark capture matches against a mode named like dark in each collection; modes: [{ collection: "Theme", mode: "Dark" }] picks one yourself.
mode: "report" measures coverage without binding; "off" skips matching. The result’s tokens section reports what happened, in the same buckets as figma_audit_adherence:
  • coverage: per bucket, how many values were bound exactly, bound within tolerance, or not matched.
  • unmatched: values with no matching token, with how often they occur, the nearest token and example layers. Report these as gaps in your design system; don’t create tokens for them unless that’s what you want.
  • drift: a CSS variable and the Figma variable with the same name have different values. That’s drift between code and design. bindOnNameMatch: true binds to the named variable anyway (the layer takes the Figma value).
  • ambiguous: several tokens matched equally well; the result names the one chosen.
Library variables are opt-in. Figma’s plugin API can only read a library variable’s value by importing it into the file, which adds a reference to it there that you can’t bulk-remove. So by default only local variables are checked, and the result names the libraries the file uses that weren’t checked (tokens.libraries.available and tokens.note). To include them:
That imports up to maxLibraryVariables (500 by default) library variables to compare, and the result says how many were added. Dry runs and mode: "report" never import library variables unless you also pass allowLibraryImport: true. Figma’s team library sometimes stops answering plugins. When it does, the import doesn’t wait: it stops reading libraries within a fixed time, warns with LIBRARY_UNAVAILABLE, and still matches local variables and styles.

Signed-in pages (attach mode)

To capture a page behind a login, Local Mode can use your own Chrome instead of a throwaway one:
  1. Start Chrome with a separate profile and a debugging port: --remote-debugging-port=9222 --user-data-dir=<a new folder>, and sign in to the site yourself.
  2. Set FIGMA_HTML_IMPORT_CDP_URL=http://127.0.0.1:9222 in your MCP config and restart the server.
Each capture then asks you to confirm before it opens a tab in that Chrome, when your client can show the question. If it can’t (or FIGMA_CONSOLE_CONFIRM_DESTRUCTIVE=off is set), captures run without asking: setting FIGMA_HTML_IMPORT_CDP_URL is your opt-in. It works in background tabs of its own, closes them when done, and never touches your other tabs. Only addresses on your own computer are accepted. click, type and press actions are off in attach mode (they would act in your signed-in session) unless you set FIGMA_HTML_IMPORT_CDP_ALLOW_ACTIONS=1. HTML strings and file:// pages always use the throwaway browser.

Cloud Mode limits

  • Public pages only. localhost, private network addresses (such as 10.x, 172.16–31.x and 192.168.x), link-local and cloud metadata addresses (169.254.169.254), names like *.local or *.internal, and single-word host names are refused with PRIVATE_ADDRESS_BLOCKED before anything loads. Every host the page loads is looked up over DNS-over-HTTPS and refused if any address it points to is private. If the lookup fails, the page isn’t loaded (DNS_UNVERIFIED). The same rules apply to baseUrl and to everything an HTML string loads. To import a dev server, use Local Mode.
  • Size: up to 6 frames per call (viewports × captured elements), 3,000 layers per frame and 8,000 per call.
  • Time: 50 seconds per viewport (timeoutMs) and 4 minutes per call (totalTimeoutMs). Larger values are lowered, with a warning.
  • Fonts: the page renders with the cloud browser’s fonts (no Apple or Microsoft system fonts), so line breaks can differ from your machine.
  • Quota: imports are counted per day for each sign-in token (25 unless the server sets HTML_IMPORT_DAILY_LIMIT), and each user runs one import at a time on a given server instance. The count follows the token, so a new personal access token or a refreshed OAuth token starts a new count: it is best-effort cost control, not a hard per-person limit. Page import needs a per-user sign-in (OAuth or a personal access token). The server’s operator can turn it off with HTML_IMPORT_CLOUD=off.
  • No file:// URLs, no attach mode, and no fileKey (Cloud pairs with one file).

Long imports, retries and cleanup

  • A large multi-viewport import can take a few minutes. In Local Mode, a client that supports MCP Tasks gets a task handle and progress, and the import keeps running past the client’s request timeout. totalTimeoutMs caps the whole call (5 minutes by default in Local Mode, up to 15).
  • In Local Mode, one import runs at a time per server. A second call while one is running answers BUSY. In Cloud Mode the limit is one import at a time per user (on each server instance), with the same BUSY answer.
  • Each call adds a new import. It never replaces an earlier one. After a timeout or an error, look at the canvas (a screenshot with figma_capture_screenshot) before you retry, or you may end up with two copies.
  • When a build fails partway, what it built is removed (onError: "cleanup", the default) and the error says “Nothing was left in the file”. onError: "keep" keeps the partial import instead. If cleanup itself can’t finish, the error names the layers to delete by hand (they start with “HTML import ·”).
  • To remove an import, delete its Section (container.nodeId when container.createdByImport is true). If you imported into your own frame or section with placement.parentId, delete only the imported frames (frames[].nodeId), never the container: it also holds your own layers. A single undo also removes the import.
  • The browser is cleaned up too. In Local Mode each import launches its own headless Chrome with a new, empty temporary profile, and closes it and deletes the profile when the import ends: after success, errors, cancellation and server shutdown. If the server is killed before it can clean up, Chrome exits with it, and the leftover profile (a figma-html-import- folder in your temp directory) is removed by the first import after the server restarts, once it is more than an hour old.
See Security for how captures are isolated.

Export for code

figma_export_assets exports what your code needs. Renders come from the live file through the Desktop Bridge: any plan, no token, and unsaved changes included.

Renders

Up to 50 nodes per call, in PNG, JPG, SVG or PDF. scale (0.01–4), width or height size PNG and JPG renders. With no format or scale, each node is exported once per setting in its Export panel, with Figma’s suffixes (@2x), the same way Figma’s own export does.

Icons as code-ready SVG

vectors: "only" exports each icon inside the set or frame as its own SVG, so a set arrow-left with Size and Style variants becomes arrow-left/24-outline.svg, arrow-left/16-solid.svg and so on. Standalone icons get their own name. Vectors are always SVG, so there’s no format. With format: "SVG" and no vectors, the set itself is rendered as one SVG of the whole set. To export particular icons, pass the variant ids with format: "SVG" instead.
  • svg.currentColor replaces the color of a single-color SVG with currentColor, so CSS can recolor it. Multi-color art is left as is, with a note.
  • svg.removeSize drops the root width and height and keeps the viewBox, so CSS sets the size.
  • svg.outlineText, svg.includeIds and svg.simplifyStroke match Figma’s SVG export options.

Icons and images inside a screen

vectors finds the layers best kept as SVG (icons, logos, simple vector art), one per main component when the same icon appears many times. Background rectangles, text and photos aren’t vectors. images exports the original image files used in fills, with the right extension. imageHashes exports images by hash directly.

Where the output goes

File names. fileName is a template without extension. Tokens: {name} (layer name; variants as set name plus values), {path} (the name with / kept, so Icon/arrow-left becomes a subfolder), {leaf} (the part after the last /), {set}, {variant}, {id}, {page}. A / in the template makes subfolders. Names are cleaned for every operating system, and two assets that would get the same name (ignoring case) get -2, -3. Existing files are kept. A file that already exists is skipped with a note unless you pass overwrite: true. Files are only ever written inside outputDir, never through a symbolic link. See Security. Renders larger than 16,384 px on a side are skipped with the largest scale that works. To just look at a design, use figma_capture_screenshot instead.

Local Mode and Cloud Mode

FIGMA_CONSOLE_ASSET_TIMEOUT_SCALE (Local Mode) multiplies the time each step waits for Figma, from 0.05 to 10. Raise it on a slow machine or for a very large file.

What to check after an import

  1. Look at it. The response’s hint names the node to screenshot with figma_capture_screenshot. Check alignment, size and color.
  2. Read the problems first. items lists failed, conflicting, skipped and updated icons first, with the reason. Created and unchanged ones are listed compactly below.
  3. Check token bindings. Each item’s color says whether a variable was applied and how many paints it bound.
  4. Publish the library if you updated icons in a library file, so other files get the new artwork when they accept the update.
  5. Continue a partial run with remaining.nextOffset (folder paging) or resumeRunId (an interrupted call).
After a page import:
  1. Screenshot each frame (figma_capture_screenshot with frames[i].nodeId) and compare it with the page. With verifyFidelity, start with worstRegions.
  2. Read warnings. BOT_CHALLENGE_DETECTED means the site showed a bot check and the capture shows the check page (it is never bypassed); a 401 or 403 in HTTP_STATUS means the page needs sign-in (attach mode); INNER_SCROLL_CONTAINER means only one screenful of an app shell was captured (expandScrollContainers).
  3. Check layoutFallbacks if you’ll edit the frames. Many absolute containers on a simple page usually mean autoLayout: "relaxed" will do better.
  4. Check fonts.substitutions and install or map the fonts that matter.
  5. Report tokens.unmatched and tokens.drift as design-system gaps. figma_audit_adherence on the frames lists every unbound value layer by layer.