Migrating from v1
Figmage v2 is a substantial rewrite of how you configure and run the tool. The core idea is unchanged — read your published Figma library and generate design tokens as code — but the config format, the commands, and the token type names are all different. This guide maps every v1 concept to its v2 equivalent so you can upgrade in one sitting.
What changed at a glance
Section titled “What changed at a glance”| Area | v1 | v2 |
|---|---|---|
| Config file | .figmage.json / .figmagerc / package.json (JSON) | figmage.config.js (JS with defineConfig) |
| Credentials | Read from env via --env | Passed explicitly as accessToken / fileId in the config |
| Commands | figmage tokenize then figmage codegen | A single figmage sync |
| Intermediate spec | A token JSON written by tokenize, consumed by codegen | None — sync goes straight from Figma to code |
| Config shape | outDir, tokenize, codegen | tokens, output, transform |
| Token source | nodeId / nodeName on the token | A source object (componentSet / frame / frameId) |
| Filtering values | include / exclude regex rules | A filter predicate function |
Step-by-step migration guide
Section titled “Step-by-step migration guide”-
Move to
figmage.config.jsv1 read configuration from a JSON file (
.figmage.json,.figmagerc, or a"figmage"key inpackage.json). v2 uses a JavaScript file,figmage.config.js, that default-exports your config. Wrap it in thedefineConfighelper for full autocompletion and type-checking.figmage.config.js import "dotenv/config";import { defineConfig } from "figmage";export default defineConfig({accessToken: process.env.FIGMA_ACCESS_TOKEN,fileId: process.env.FIGMA_FILE_ID,tokens: [{ name: "colors", type: "color" }],});Delete your old
.figmage.json/.figmagerconce you’ve ported the settings, and remove the"figmage"key frompackage.jsonif you used that. See Configuration for the full reference. -
Pass credentials in the config
In v1 the access token and file ID were read implicitly from the environment, and you pointed at a custom env file with
--env. In v2 you load the environment yourself (e.g. withdotenv) and pass the values explicitly todefineConfig:import "dotenv/config";import { defineConfig } from "figmage";export default defineConfig({accessToken: process.env.FIGMA_ACCESS_TOKEN,fileId: process.env.FIGMA_FILE_ID,// ...});The env variable names are unchanged (
FIGMA_ACCESS_TOKEN,FIGMA_FILE_ID), so your existing.envfile keeps working. See Install and Auth for details. -
Replace
tokenize+codegenwithsyncv1 was a two-step pipeline:
Terminal window # v1figmage tokenize # fetch from Figma, write an intermediate token JSON specfigmage codegen # turn that spec into codev2 collapses this into a single command — there is no intermediate spec to generate or commit:
Terminal window # v2figmage syncIf your CI or scripts called
tokenizeandcodegenseparately, replace both withfigmage sync. You can now narrow a run with--onlyand--skip:Terminal window figmage sync --only=colors,typographyfigmage sync --skip=iconsThe full command reference, including the global
--verboseflag, lives in the CLI reference. -
Restructure the config
The top-level shape changed. v1 nested everything under
tokenizeandcodegenand usedoutDir; v2 has a flattokensarray plusoutputandtransformfor defaults.v1
{"outDir": "tokens","tokenize": {"tokens": [{ "name": "colors", "type": "color" },{ "name": "typography", "type": "text" }]},"codegen": {"defaults": { "filetype": "ts", "tokenCase": "camel" },"typography": { "filetype": "json", "tokenCase": "kebab" }}}v2
export default defineConfig({accessToken: process.env.FIGMA_ACCESS_TOKEN,fileId: process.env.FIGMA_FILE_ID,output: { directory: "./tokens", fileType: "ts" },transform: { defaultCasing: "camel" },tokens: [{ name: "colors", type: "color" },{name: "typography",type: "text",output: { fileType: "json" },transform: { casing: "kebab" },},],});Key mappings:
v1 v2 outDiroutput.directorycodegen.defaults.filetypeoutput.fileTypecodegen.defaults.tokenCasetransform.defaultCasingcodegen.[token].filenameper-token output.fileNamecodegen.[token].filetypeper-token output.fileTypecodegen.[token].tokenCaseper-token transform.casing -
Update token types and sources
Several token
typenames were renamed, and component-based tokens now use asourceobject instead ofnodeId/nodeName.v1 type v2 type Notes colorcolorUnchanged texttextUnchanged drop-shadowdropShadowRenamed (camelCase) widthproperty+source.property: "absoluteBoundingBox.width"Now a measured property heightproperty+source.property: "absoluteBoundingBox.height"Now a measured property dimensionsproperty(measure each dimension separately)Use one propertytoken per dimensionradiusproperty+source.property: "cornerRadius"Now a measured property svgimageVectororimageSpriteimageVectorfor files;imageSpritefor a sprite sheetpngimageRasterRenamed; formatcan bepngorjpgSources:
Section titled “Sources: nodeId / nodeName → source”nodeId/nodeName→sourcev1 pointed at the frame containing your components with
nodeIdornodeNamedirectly on the token. v2 moves this to asourceobject and addscomponentSetas an option:// v1{ "name": "icons", "nodeId": "123:456", "type": "svg" }{ "name": "spacing", "nodeName": "My Spacing", "type": "height" }// v2{ name: "icons", type: "imageVector", source: { frameId: "123:456" } }{name: "spacing",type: "property",source: { frame: "My Spacing", property: "absoluteBoundingBox.height" },}sourceacceptscomponentSet,frame(by name), orframeId(thenode-idfrom the Figma URL). See Token Types for the complete catalog.SVG color conversion moved
Section titled “SVG color conversion moved”v1 disabled
currentColorconversion withoptions.convertColors. v2 expresses SVG processing as SVGO overrides undertransform.optimize:// v1{ "name": "icons-multicolor", "nodeId": "y:y", "type": "svg", "options": { "convertColors": false } }// v2{name: "icons-multicolor",type: "imageVector",source: { frame: "Icons Multicolor" },transform: { optimize: [["convertColors", false]] },} -
Replace include/exclude rules with
filterv1 filtered individual tokens with
include/excludeobjects of regex or exact-match strings ongroupandtoken. v2 replaces these with a singlefilterpredicate function — plain JavaScript, no escaped regex strings required.// v1{"codegen": {"colors": {"exclude": { "token": "^\\bFigma\\b.*" }}}}// v2{name: "colors",type: "color",filter: ({ name }) => !name.startsWith("Figma"),}The predicate receives
{ name, value, group }, so you can filter on a token’s name, value, or group. To select whole token sets at runtime, use--only/--skipinstead. -
Update the
spritesheetcommand flagsThe standalone
figmage spritesheetcommand still bundles local SVG files, but several flags were renamed and the IDs output is now configured with dedicated flags.v1 flag v2 flag --sprite-input--sprite-input--sprite-out-dir--sprite-output(implicit filename) --sprite-filename(required)--sprite-ids-out-dir--sprite-ids-output(with--sprite-ids-enabled)--sprite-case--sprite-case--sprite-convert-colors--sprite-convert-colorsTerminal window # v1figmage spritesheet \--sprite-input ./icons \--sprite-out-dir ./public \--sprite-ids-out-dir ./app/components# v2figmage spritesheet \--sprite-input ./icons \--sprite-output ./public \--sprite-filename icon-sprite \--sprite-ids-enabled \--sprite-ids-output ./src/tokens \--sprite-ids-filename icon-sprite-idsSee the full flag list in the CLI reference.
Migration checklist
Section titled “Migration checklist”- Upgrade the package:
npm install --save-dev figmage@latest. - Create
figmage.config.jsand port your settings, deleting the old JSON config. - Pass
accessTokenandfileIdexplicitly (load your.envwithdotenv). - Move
outDir→output.directoryandcodegen.defaults→output/transform. - Rename token types and convert
nodeId/nodeNametosource. - Replace
include/excluderules withfilterpredicates. - Swap
tokenize+codegenforfigmage syncin all scripts and CI. - Update any
figmage spritesheetinvocations to the new flags.
Where to go next
Section titled “Where to go next”- Quickstart — a fresh five-minute setup with the v2 flow.
- Configuration — every field in
figmage.config.js. - Token Types — the full v2 token catalog.
- Spritesheets — generate SVG sprite sheets for your icons.
- CLI — the
syncandspritesheetcommands.