As discussed in Halliday and Resnick’s “Fundamentals of Physcis,” Hooke’s law states that the formula relating the force a spring exerts, as a function of its displacement from its equilibrium length, is force F = -kx. x here is a measure of the displacement of the free end of the spring from its unloaded, unstressed position. k is a proportionality constant called the "stiffness," and is specific to each spring. The minus sign is in front because the force that the spring exerts is a “returning” force, meaning that it opposes the direction of displacement x, in an effort to return the spring to its unloaded position. The spring equation usually holds for displacement x in both directions--both stretching and compressing displacement--although there can be exceptions. If you don’t know k for a specific spring, you can calibrate your spring using a weight of known mass.
Determine the position of the free end of the spring, if hanging loosely--its other end affixed to something solid like a wall.
Decide what displacement x from the equilibrium position you want to know the spring force, measuring it in meters.
Multiply x by -k to find the force that the spring exerts to try to return to its equilibrium position. If x is in meters and k is in kilograms per second-squared, then force F is in Newtons, the SI unit for force.
If you don’t know k, proceed to the next step to determine it.
Find the spring’s proportionality constant k by hanging a weight of known mass m, preferably in kilograms, from the free end of the spring, after positioning it vertically. From the resulting displacement, you can determine k by the relation k = -mg/x, where g is the gravitational acceleration constant 9.80m/s^2, where the caret ^ indicates exponentiation.
For example, if the spring displaces x = 5 centimeters under a load of 5 kilograms, then k = - 5kg x 9.80 m/s^2 / (-0.05m) = 980 kg/s^2. So then you can subsequently solve for its restoring force F when the displacement x is, say, 10cm, as follows F = (-980 kg/s^2)(0.10m) = -9.8 Newtons.
The formula is accurate only up to a point. For large x it will not be accurate. Displacement x in both directions will not necessarily effect the same magnitude of restoring force, e.g. if the turns of the spring's coil are tightly bound in the relaxed, equilibrium position.