Extract node rotation angle from Figma API JSON response

I’m working with the Figma API to fetch document data and I need to figure out how to determine the rotation value of elements. When I pull the JSON data from a Figma file, I can see various properties for each node but I’m having trouble understanding where the rotation information is stored or how to calculate it from the available data. The API documentation doesn’t make it super clear to me. Has anyone worked with this before and knows which property contains the rotation data? Or do I need to derive it from other transformation values? I’m specifically looking at text boxes and shapes that have been rotated in the Figma design. Any help would be great since I’m stuck on this part of my project.

yeah i had this issue too! check the transform property on the node - sometimes its there instead of relativeTransform depending on how the element was rotated. also worth noting that nested elements might inherit rotation from parent groups so you might need to traverse up the tree to get the full rotation value.

The rotation data in Figma API responses is typically found within the relativeTransform matrix property of each node. This is a 2x3 transformation matrix that contains all the geometric transformations including rotation, scaling, and translation. To extract just the rotation angle, you’ll need to calculate it from the matrix values using Math.atan2(matrix[1][0], matrix[0][0]) which gives you the angle in radians. Convert to degrees by multiplying by 180/Math.PI. I ran into this same issue when building a Figma plugin last year and initially overlooked the transform matrix thinking rotation would be a separate property. The matrix approach works reliably for all rotated elements including text and shapes.

From my experience working with Figma’s API, there’s another edge case worth mentioning that caught me off guard. When dealing with auto-layout frames or components that have been rotated, the rotation behavior can be inconsistent compared to regular shapes. I found that some rotated auto-layout containers would return unexpected matrix values, particularly when they contained text elements with different baseline alignments. The calculation method Pete_Magic mentioned works perfectly for most cases, but I had to add additional validation to handle these special frame types. Also, keep in mind that Figma sometimes applies micro-rotations during certain design operations that result in very small decimal values instead of clean angles like 90 or 45 degrees. You might want to implement some rounding logic to handle these cases if you’re expecting specific angle values in your application.

One thing to watch out for is that the relativeTransform matrix might not always be present in the JSON response. I’ve encountered cases where elements that haven’t been explicitly transformed in Figma don’t include this property at all, which can cause errors if you’re not checking for its existence first. Also, be aware that compound rotations can get tricky - if you have multiple nested groups with different rotations applied, you’ll need to multiply the transformation matrices together to get the final rotation value. I learned this the hard way when some of my calculated angles were completely off. Always validate that the relativeTransform exists before trying to extract rotation data from it, otherwise your code will break on non-rotated elements.