Rearranging the formula to solve for G, we get $G = \frac{F r^2}{m_1 m_2}$. Substituting the SI units for force (N), distance (m), and mass (kg), the unit of G is $\frac{N \cdot m^2}{kg \cdot kg} = N m^2 kg^{-2}$.