The magnitude of the spring force is dictated by two quantities: The stiffness of the spring, which is given by the spring constant, k, and the amount of stretch (or compression) in the spring. The stretch in the spring is given by the variable x, which is measured relative to the equilibrium position (that is, the unstretched position of the spring), which defines the position x = 0 (as is shown in the diagram at left). The magnitude of the spring force is then given by
Fsp = kx .
The direction of the spring force is opposite to the displacement of the end of the spring relative to the equilibrium position. Thus, for example, in the figure above, the spring is stretched to the right from its equilibrium position (at x = 0), so that the spring force acting on the mass m points towards the left. (Likewise, if the spring were compressed to the left beyond the equilibrium position, then the spring force acting on the mass would be pointing towards the right.)
Note that, since force has MKS units of newtons (N), and the distance x has units of meters (m), then the units of the spring constant, k must be N /m (as can be seen by solving the equation above for k).