Skip to content

CLI Reference ​

Document commands accept a .fig file as a positional argument. When omitted, the CLI connects to the running desktop app via RPC. documents, undo, redo, and settings always act on the running app.

info ​

Show document info — pages, node counts, fonts, file size.

sh
openpencil info [file] [--json]
OptionDescription
--jsonOutput as JSON

tree ​

Print the node hierarchy.

sh
openpencil tree [file] [options]
OptionDescription
--pagePage name (default: first page)
--depthMax depth (default: unlimited)
--jsonOutput as JSON

find ​

Search nodes by name or type.

sh
openpencil find [file] [options]
OptionDescription
--nameNode name (partial match, case-insensitive)
--typeNode type: FRAME, TEXT, RECTANGLE, INSTANCE, etc.
--pagePage name (default: all pages)
--limitMax results (default: 100)
--jsonOutput as JSON

node ​

Show detailed properties of a node.

sh
openpencil node [file] --id <id> [--json]
OptionDescription
--idRequired. Node ID (e.g. 1:23)
--jsonOutput as JSON

pages ​

List all pages in the document.

sh
openpencil pages [file] [--json]
OptionDescription
--jsonOutput as JSON

variables ​

List design variables and collections.

sh
openpencil variables [file] [options]
OptionDescription
--collectionFilter by collection name
--typeFilter by type: COLOR, FLOAT, STRING, BOOLEAN
--jsonOutput as JSON

tokens ​

Print design variables as a stylesheet of CSS custom properties. Default mode values go in :root; every other mode overrides them under its condition, [data-<collection>="<mode>"] unless the mode names a selector or @media query. Aliases stay var() references. Tokens or modes that cannot be written are listed on stderr.

sh
openpencil tokens [file] [options]
OptionDescription
--formatcss (default), tailwind for a Tailwind v4 @theme with a @custom-variant per mode, or dtcg for W3C design token files
--out, -oFolder the dtcg files are written to; required for that format
--collectionFilter by collection name
--typeFilter by type: COLOR, FLOAT, STRING, BOOLEAN
--jsonOutput { css, tokenCount, issues } as JSON

export ​

Export to PNG, JPG, WEBP, SVG, JSX, HTML, .fig, or Storybook stories.

sh
openpencil export [file] [options]
OptionAliasDescription
--format-fpng (default), jpg, webp, svg, pdf, pptx, jsx, tailwind-jsx, html, fig, storybook
--output-oOutput file path (default: <name>.<format>); a directory for storybook (default: <name>-stories)
--scale-sExport scale (default: 1)
--quality-qQuality 0–100, JPG/WEBP only (default: 90)
--pagePage name (default: first page; fig, pptx, and storybook default to every page)
--nodeNode ID to export (default: all top-level nodes)
--styleJSX style: openpencil (default), tailwind (same as -f tailwind-jsx)
--htmlHTML mode: fragment (default), standalone
--cssHTML CSS output: inline (default), tailwind
--assetsStandalone HTML assets: inline (default), external
--fontsStandalone HTML font output: assets, none (default)
--frameworkStorybook framework: react (default), vue, html
--design-imagesStorybook: render a PNG per variant for the Design panel (default: on; --no-design-images to skip)
--watchStorybook: re-export whenever the document is saved
--besideStorybook: write each document's stories into the document's own folder; the file argument can then be several files or a quoted glob
--thumbnailExport page thumbnail instead of full render
--widthThumbnail width (default: 1920)
--heightThumbnail height (default: 1080)

import ​

Import HTML/CSS/Tailwind into an editable 4B Pen document.

sh
openpencil import page.html [options]
OptionAliasDescription
--format-fOutput format: fig (default), json
--output-oOutput file path (default: <name>.<format>)
--cssCSS file to apply before conversion
--css-textInline CSS text to apply before conversion
--tailwindTailwind utility candidates to compile and apply
--tailwind-fileFile containing Tailwind utility candidates
--page-nameScene graph page name (default: DOM/CSS)
--jsonPrint a machine-readable summary

Examples:

sh
openpencil import card.html --css card.css -o card.fig
openpencil import card.html --tailwind "flex flex-col gap-3 w-80 p-6 rounded-xl bg-white" -o card.fig

eval ​

Execute JavaScript with the Figma Plugin API.

sh
openpencil eval [file] [options]
OptionAliasDescription
--code-cJavaScript code to execute
--stdinRead code from stdin
--write-wWrite changes back to the input file
--output-oWrite to a different file
--jsonOutput as JSON
--quiet-qSuppress output

analyze colors ​

Analyze color palette usage across the document.

sh
openpencil analyze colors [file] [options]
OptionDescription
--limitMax colors to show (default: 30)
--thresholdDistance threshold for clustering similar colors, 0–50 (default: 15)
--similarShow similar color clusters
--jsonOutput as JSON

analyze typography ​

Analyze font family, size, and weight distribution.

sh
openpencil analyze typography [file] [options]
OptionDescription
--group-byGroup by: family, size, weight (default: show all styles)
--limitMax styles to show (default: 30)
--jsonOutput as JSON

analyze spacing ​

Analyze gap and padding values across auto-layout frames.

sh
openpencil analyze spacing [file] [options]
OptionDescription
--gridBase grid size to check against (default: 8)
--jsonOutput as JSON

analyze clusters ​

Find repeated node patterns — potential components.

sh
openpencil analyze clusters [file] [options]
OptionDescription
--limitMax clusters to show (default: 20)
--min-sizeMin node size in px (default: 30)
--min-countMin instances to form a cluster (default: 2)
--jsonOutput as JSON

diff create ​

Patch that turns one node tree into another, as JSX attribute changes plus moved, added, and removed children. Children match by name; see Comparing designs for the format.

sh
openpencil diff create [file] --from <id> --to <id> [options]
OptionDescription
--fromSource node ID
--toTarget node ID
--depthMax tree depth (default: 10)
--jsonOutput as JSON

diff jsx ​

Structural diff between two nodes as design JSX.

sh
openpencil diff jsx [file] --from <id> --to <id> [--json]

diff show ​

Preview the patch that setting JSX attributes on a node would produce, without changing it.

sh
openpencil diff show <id> [file] --attributes '<jsx attributes>' [--json]

--attributes takes attributes as the JSX export writes them, such as 'w={200} bg="#FF0000"'.

diff apply ​

Apply a patch from diff create, diff show, or diff files. Every node must still match the patch's old values unless --force is set, and nothing changes unless every hunk applies.

sh
openpencil diff apply <patch> [file] [options]
OptionAliasDescription
--dry-runValidate and list changes without applying
--forceApply even when current values differ from the patch
--write-wWrite changes back to the input file
--output-oWrite to a different file
--jsonOutput as JSON

Pass - as the patch path to read it from stdin.

diff visual ​

Pixel diff between two rendered nodes, written as a PNG with changed pixels in red.

sh
openpencil diff visual [file] --from <id> --to <id> --output <png> [options]
OptionAliasDescription
--output-oDiff PNG path
--scaleRender scale before the max-edge limit (default: 1)
--max-edgeMaximum image width or height (default: 1280)
--thresholdColor tolerance 0–1; smaller is stricter (default: 0.1)
--jsonOutput as JSON

diff files ​

Structural diff of two documents, page by page. Pages match by name and nodes by name path, so two versions of a file compare even though their node IDs differ. Exits with status 1 when the documents differ and 2 when the options are invalid, such as a --page neither document has.

sh
openpencil diff files <before> <after> [options]
OptionDescription
--pageCompare only the page with this name
--depthMax tree depth below each page (default: unlimited)
--jsonOutput as JSON

documents ​

Manage documents (tabs) in the running app. See Controlling the App.

sh
openpencil documents list [--json]
openpencil documents open <file> [--json]
openpencil documents new [--path <file>] [--json]
openpencil documents save [--path <file>] [--document-id <id>] [--json]
openpencil documents close [--save | --discard] [--path <file>] [--document-id <id>] [--json]
openpencil documents activate <document-id> [--page-id <id>] [--json]
OptionDescription
--path.fig path to create or save to; relative to the current directory
--saveclose: save unsaved changes first
--discardclose: close without saving; unsaved changes are lost
--document-idTarget document; defaults to the active tab
--page-idPage to switch the activated document to
--jsonOutput the result and target document as JSON

undo / redo ​

Undo or redo the newest change made through the CLI or MCP in the running app. Fails when the newest change was made in the editor; see Controlling the App.

sh
openpencil undo [--document-id <id>] [--json]
openpencil redo [--document-id <id>] [--json]

settings ​

Read and change editor settings in the running app by dotted key. Values parse as JSON, falling back to plain strings.

sh
openpencil settings get [key] [--json]
openpencil settings set <key> <value> [--json]

See Controlling the App for the available keys.

tool ​

List, describe, and call the editor tools that the MCP server exposes.

sh
openpencil tool list [--json]
openpencil tool describe <name> [--json]
openpencil tool call <name> [file] [options]
OptionAliasDescription
--argsTool arguments as a JSON object
--args-fileRead arguments from a JSON file, or - for stdin
--write-wHeadless: write changes back to the input file
--output-oHeadless: write changes to a different file
--document-idApp: target document
--page-idApp: target page
--jsonOutput as JSON

Released under the MIT License.