Back PJ Onori’s code

Count Figma layers

A simple script to count all layers from an entire Figma file. Be patient, this script can take time time to run.

Instructions

This script is intended to run within Figma through its plugin API. The fastest way to run this script is by copy-pasting within Scripter.

                
await figma.loadAllPagesAsync();

function countLayers(node) {
  let layers = 0;

  function recurse(node) {
    layers++;
    if ("children" in node) {
      for (const child of node.children) {
        recurse(child);
      }
    }
  }

  recurse(node);
  return layers;
}
countLayers(figma.root);