Skip to content

Instantly share code, notes, and snippets.

@ryohey
Last active March 11, 2021 21:16
Show Gist options
  • Save ryohey/30b16fb89ec49cee8e8313658a347e6b to your computer and use it in GitHub Desktop.
Save ryohey/30b16fb89ec49cee8e8313658a347e6b to your computer and use it in GitHub Desktop.
Detach and flatten all frames in Figma
const detachAndFlatten = (pageName) => {
const detach = (c) => figma.union([c], c.parent)
const page = figma.root.children.find(c => c.name === pageName)
const frames = page.children.filter(c => c.type === "FRAME")
for (let frame of frames) {
for (let c of frame.children) {
if (c.type === "INSTANCE") {
c = detach(c)
} else {
//
}
figma.flatten([c])
}
}
}
@ryohey
Copy link
Author

ryohey commented Jun 29, 2020

Usage

  1. Open the console in Figma
  2. Paste the code
  3. type detachAndFlatten("here is your page name")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment