Abstract Interior modeling of Jupiter and Saturn has advanced to a state where thousands of models are generated that cover the uncertainty space of many parameters. This approach demands a fast method of computing their gravity field and shape. Moreover, the Cassini mission at Saturn and the ongoing Juno mission delivered gravitational harmonics up to J 12. Here we report the expansion of the theory of figures, which is a fast method for gravity field and shape computation, to the seventh order (ToF7), which allows for computation of up to J 14. We apply three different codes to compare the accuracy using polytropic models. We apply ToF7 to Jupiter and Saturn interior models in conjunction with CMS-19 H/He equation of state. For Jupiter, we find that J 6 is best matched by a transition from an He-depleted to He-enriched envelope at 2–2.5 Mbar. However, the atmospheric metallicity reaches 1 × solar only if the adiabat is perturbed toward lower densities, or if the surface temperature is enhanced by ∼14 K from the Galileo value. Our Saturn models imply a largely homogeneous-in-Z envelope at 1.5–4 × solar atop a small core. Perturbing the adiabat yields metallicity profiles with extended, heavy-element-enriched deep interior (diffuse core) out to 0.4 R Sat, as for Jupiter. Classical models with compact, dilute, or no core are possible as long as the deep interior is enriched in heavy elements. Including a thermal wind fitted to the observed wind speeds, representative Jupiter and Saturn models are consistent with all observed J n values.