Skip to main content

Hooke’s Law Calculator

Calculate the restoring force, spring constant, extension or compression of a spring and its elastic potential energy, with every calculation step.

Embed this widget

Customize the result, check the live preview, then copy the code.

Preview

Embed code type

Code to copy

Responsive and automatically resized by Bethemesh.

Fill in two quantities and leave the other two empty. The displacement is signed: positive for extension, negative for compression. The restoring force has the opposite sign.

Model: an ideal, massless spring used within its linear elastic range. Beyond the elastic limit, F = −kx no longer applies and the spring may stay permanently deformed.

Results

Restoring force F (signed)
-
Magnitude |F|
-
Spring state
-
Spring constant k
-
Displacement x
-
Elastic energy E
-

Spring diagram

The dashed line marks the equilibrium position; the arrow shows the direction of the restoring force.

Calculation steps

    Was this tool useful?

    On this page

    How does this tool work?

    Pull on a spring and it resists more the further you stretch it. Hooke’s law expresses this proportionality between the restoring force and the deformation. The calculator finds the force, the spring constant, the extension or compression and the elastic potential energy from any two of these quantities, with a diagram showing the direction of the force.

    The tool applies F = −kx to values converted into SI units: newtons, metres and newtons per metre. x is the displacement of the free end from the spring’s natural length, positive for extension and negative for compression. The minus sign shows that the force exerted by the spring always opposes the deformation: it pulls or pushes the object back towards equilibrium. The magnitude |F| = k|x| is the value you compare with a load.

    The spring constant k is the force needed to deform the spring by one unit of length. It is strictly positive. A small mechanism spring may have a stiffness of a few hundred N/m, a car suspension spring several tens of thousands. Datasheets often give it in N/mm: 1 N/mm equals 1,000 N/m.

    The elastic potential energy E = ½kx² is the work done to deform the spring, which it can give back when it returns to equilibrium. It depends on the square of the displacement: doubling the extension quadruples the energy. It is the same for an extension and a compression of equal size.

    Two quantities are enough to determine the other two. If you only know k and E, the energy fixes |x| but not the direction of the deformation, so the tool shows ±x and ∓F. A zero or negative stiffness, a negative energy, F and x with the same sign, or a result outside the representable range is rejected.

    How to use this tool

    1. Choose the two unknowns

      Leave the two fields to calculate empty and fill in the other two. Zero is a known value.

    2. Enter values and units

      Give the displacement with its sign (negative for compression), then the spring constant in N/m, N/mm or lbf/in.

    3. Read the result and the diagram

      Check the signed force, its magnitude, the stored energy, the steps in SI units and the direction of the force on the diagram.

    Hooke’s law and elastic energy

    Restoring force

    F = −k × x

    Signed: always opposite in sign to the displacement.

    Magnitude of the force

    |F| = k × |x|

    Absolute value of the restoring force.

    Elastic potential energy

    E = ½ × k × x²

    In joules when k is in N/m and x in metres.

    Find the spring constant

    k = −F / x = 2E / x²

    The displacement must be nonzero.

    Find the displacement

    x = −F / k ; |x| = √(2E / k)

    The energy alone does not give the direction of the deformation.

    F
    Signed restoring force exerted by the spring, in newtons (N).
    k
    Spring constant, strictly positive, in newtons per metre (N/m).
    x
    Displacement from the natural length, in metres (m): positive for extension, negative for compression.
    E
    Stored elastic potential energy, in joules (J).

    Use cases

    Choose a spring

    Check the force produced for a given travel, or the stiffness needed to carry a load without exceeding a deflection.

    Analyse a lab test

    Work out a spring constant from a measured force and extension, then the stored energy.

    Prepare an energy balance

    Calculate the elastic energy of a spring launcher before converting it into kinetic or gravitational potential energy.

    Examples

    Spring stretched by 5 cm

    With x = 0.05 m, F = −200 × 0.05 = −10 N: the spring pulls the object back towards equilibrium. The energy is ½ × 200 × 0.05² = 0.25 J.

    Input

    Force: empty field
    Spring constant: 200 N/m
    Displacement: 5 cm
    Energy: empty field

    Result

    Restoring force: −10 N
    Elastic energy: 0.25 J
    State: extension

    Spring constant from a compression test

    The spring compressed by 3 cm pushes with 12 N: k = −12 / (−0.03) = 400 N/m. A positive force with a positive displacement would be rejected as physically inconsistent.

    Input

    Force: 12 N
    Spring constant: empty field
    Displacement: −3 cm
    Energy: empty field

    Result

    Spring constant: 400 N/m
    Elastic energy: 0.18 J
    State: compression

    Deformation from stored energy

    25 N/mm is 25,000 N/m; |x| = √(2 × 0.5 / 25,000) ≈ 0.00632 m. The energy does not tell whether the spring is stretched or compressed, hence both signs.

    Input

    Force: empty field
    Spring constant: 25 N/mm
    Displacement: empty field, unit mm
    Energy: 0.5 J

    Result

    Displacement: ±6.3245553 mm
    Restoring force: ∓158.11388 N

    Spring constant from energy and extension

    k = 2 × 4 / 0.2² = 200 N/m, then F = −200 × 0.2 = −40 N.

    Input

    Force: empty field
    Spring constant: empty field
    Displacement: 20 cm
    Energy: 4 J

    Result

    Spring constant: 200 N/m
    Restoring force: −40 N

    Tips and best practices

    • To measure a spring constant, hang a known mass and measure the extension at equilibrium: the weight mg then equals kx.
    • Measure x from the spring’s natural length, not from its total length.
    • For a compression spring, check that the required travel does not exceed the solid length given by the manufacturer.
    • If the extension stops being proportional to the load during a test, you have left the linear elastic range and the result is no longer reliable.

    Sources and references

    Frequently asked questions

    Why is there a minus sign in F = −kx?

    It shows that the spring force opposes the displacement. A stretched spring pulls back; a compressed spring pushes out. Without the sign, you only get the magnitude k|x|.

    What is the difference between extension and compression?

    Extension (x > 0) stretches the spring beyond its natural length; compression (x < 0) shortens it. In the linear range the same constant applies to both, but extension and compression springs are often different parts.

    How do I measure a spring constant?

    Hang a mass m and measure the extension x at equilibrium: k = mg/x. A 500 g mass that stretches the spring by 2.45 cm gives about 4.9 N / 0.0245 m ≈ 200 N/m.

    Why are there two solutions when I know k and E?

    The energy depends on x², so an extension and a compression of the same size store the same energy. You need another piece of information, such as the sign of the force or of the displacement, to decide.

    Does Hooke’s law apply to rubber bands?

    Only approximately and over a small range: rubber behaves non-linearly. For a material, the law is usually written in terms of stress and strain, using Young’s modulus.

    Related tools

    Tools similar or complementary to this one.

    Works well with