In this paper we prove a sub-Riemannian version of the classical Santaló formula: a result in integral geometry that describes the intrinsic Liouville measure on the unit cotangent bundle in terms of the geodesic flow. Our construction works under quite general assumptions, satisfied by any sub-Riemannian structure associated with a Riemannian foliation with totally geodesic leaves (e.g. CR and QC manifolds with symmetries), any Carnot group, and some non-equiregular structures such as the Martinet one. A key ingredient is a "reduction procedure" that allows to consider only a simple subset of sub-Riemannian geodesics.As an application, we derive isoperimetric-type and (p-)Hardy-type inequalities for a compact domain M with piecewise C 1,1 boundary, and a universal lower bound for the first Dirichlet eigenvalue λ1(M ) of the sub-Laplacian, λ1(M ) ≥ kπ 2 L 2 , in terms of the rank k of the distribution and the length L of the longest reduced sub-Riemannian geodesic contained in M . All our results are sharp for the sub-Riemannian structures on the hemispheres of the complex and quaternionic Hopf fibrations:where the sub-Laplacian is the standard hypoelliptic operator of CR and QC geometries, L = π and k = 2d or 4d, respectively.1 Abnormal geodesics are allowed, but strictly abnormal ones, not given by the Hamiltonian flow on the cotangent bundle, do not play any role in our construction. 2 We stress that Carnot groups are not Riemannian foliations if their step is > 2.