Figma Script Generator

Generates custom JavaScript scripts optimized for execution within the Figma Inspect Console, leveraging the Figma API for automation and design manipulation.

FigmaDesignAutomation

Input

Output

Animated Dancing Icon

Your creation's spotlight zone

Example

/**
 * Change the fill of all selected layers to a random solid color.
 * To use: Paste into Figma Console (Command + Option + I)
 */

function getRandomColor() {
  return {
    r: Math.random(),
    g: Math.random(),
    b: Math.random()
  };
}

const selection = figma.currentPage.selection;

if (selection.length === 0) {
  console.log("Please select at least one layer.");
} else {
  for (const node of selection) {
    if ("fills" in node && Array.isArray(node.fills)) {
      const fills = structuredClone(node.fills);
      fills[0] = {
        type: "SOLID",
        color: getRandomColor(),
        opacity: 1
      };
      node.fills = fills;
    }
  }

  console.log("Random colors applied 🎨");
}