A general scaling law connecting the stiffness and dissipative properties of a linear mechanical oscillator immersed in a viscous fluid is derived. This enables the noninvasive experimental determination of the stiffness of small elastic bodies of arbitrary shape by measuring their resonant frequency and quality factor in fluid (typically air). In so doing, we elucidate the physical basis of the method of Sader etal [Rev. Sci. Instrum. 70, 3967 (1999)] for determining the stiffness of rectangular atomic force microscope cantilevers, and discuss its applicability. The validity of the derived general technique is demonstrated by calibrating atomic force microscope cantilevers with complex geometries, and its implications to small bodies in general are discussed.