  We report on a comprehensive investigation of the effects of strain and film
thickness on the structural and magnetic properties of epitaxial thin films of
the prototypal $J_\mathrm{eff}=1/2$ compound Sr$_2$IrO$_4$ by advanced X-ray
scattering. We find that the Sr$_2$IrO$_4$ thin films can be grown fully
strained up to a thickness of 108 nm. By using X-ray resonant scattering, we
show that the out-of-plane magnetic correlation length is strongly dependent on
the thin film thickness, but independent of the strain state of the thin films.
This can be used as a finely tuned dial to adjust the out-of-plane magnetic
correlation length and transform the magnetic anisotropy from two-dimensional
(2D) to three-dimensional (3D) behavior by incrementing film thickness. These
results provide a clearer picture for the systematic control of the magnetic
degrees of freedom in epitaxial thin films of Sr$_2$IrO$_4$ and bring to light
the potential for a rich playground to explore the physics of $5d$-transition
metal compounds.
