The study of rock fabric properties (orientation, planar, linear, anisotropy) is key to unravelling the geological processes that generated them. With advancements in data acquisition and treatment, X-ray micro-computed tomography (μXCT) represents a powerful method to analyse the shape preferred orientation (SPO) of rockforming elements, including minerals, aggregates, and pores, in the three-dimensional space. After reconstruction and segmentation of μXCT images, we developed a novel protocol to construct and analyse the fabric tensor, a second-rank symmetric tensor constructed using the orientation and the length of the three characteristic axes of each grain (simplified to a best fit ellipsoid). The analysis of the fabric tensor permits calculation of mean principal directions and associated confidence ellipses, and quantifies the degree of anisotropy (P 0 ) and the shape (T) of the fabric ellipsoid by eigenvalue and eigenvector analysis.We implement this method in the TomoFab open-source MATLAB package. The code integrates a graphical user interface (GUI) that allows the visualisation of the full set of ellipsoid orientation, shape, and size. Density plots and contouring can be utilised to identify fabrics graphically, and a full set of fabric parameters can be calculated based on the analysis of the fabric tensor and/or the analysis of each principal direction orientation tensor.We demonstrate the versatility of TomoFab with synthetic datasets and a field-and laboratory-based investigation of a sample presenting a magmatic foliation and lineation, collected in the Mafic Complex within the lower crustal section of the Ivrea-Verbano Zone (North Italy). In the light of these developments, we stress that μXCT represents a pertinent tool for rock fabric analysis to characterise the SPO of rock components. This approach can be performed parallel or complementary to other rock fabric quantification methods (e.g., AMS, EBSD) and applied to various rock types.