Hooke's law calculator
A spring with a constant of 10 N/m stretched by 2 m pulls with 20 N. Enter any two of force, spring constant and displacement and get the third from Hooke's law F = kx, for one ideal spring. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Spring constant k
- 10
- Displacement x from equilibrium
- 2
- Force
- 20
- Solved
- force
Hooke's law is the shortest path from a stretched or compressed spring to a number you can check: force equals spring constant times displacement.
What F = kx means and which two quantities you need to send
In introductory mechanics, an ideal linear spring obeys Hooke's law: the magnitude relationship written as F equals k times x, where F is the spring force along a chosen axis, k is the positive spring constant or stiffness, and x is the displacement from the unstretched equilibrium length.
That identity is the backbone of classroom problem sets, lab calibration of force sensors, and countless engineering estimates: how much force does a known k produce at a given extension, what extension produces a target load, or what stiffness is implied by a measured force and displacement pair. Search intent clusters around phrases such as Hooke's law calculator, spring force calculator, F equals k x calculator, spring constant from force and displacement, and displacement from force and spring constant.
People want a numeric answer they can check against a worksheet, embed in a simulation, or feed into a larger pipeline—not only a reminder that the formula exists. Units stay consistent with whatever force and length basis you chose: newtons with metres and newtons per metre, or any coherent set you prefer.
How this calculator validates input and applies F = kx
Numeric strings that parse to finite numbers are accepted so forms and CSV-style pipelines can pass values without an extra cast. Zero spring constant on input is also refused so division and trivial stiffness never sneak through. When spring constant is the unknown, displacement must be non-zero to avoid division by zero.
After validation, the missing quantity is computed as force equals spring constant times displacement, or displacement equals force over spring constant, or spring constant equals force over displacement. Signed force and displacement are allowed: negative values reverse the sense of the axis under the F equals k x form. There is no damper, no multi-spring network, and no unit conversion; this is ideal one-dimensional Hooke's law from the two known quantities.
Practical use, limits, pricing, and delivery channels
Use the browser tool when you want an immediate Hooke's law check while grading homework, verifying a lab spring stretch series, sanity-checking a game physics stiffness, or sizing how far a spring must move for a design load. Choose units consistently—if force is in newtons and displacement is in metres, spring constant comes out in newtons per metre. Results are fully deterministic: the same two inputs always yield the same triad and the same solved field label.
There is no language model, no external physics service, and no randomness, so the capacity is safe to pin in continuous-integration checks and reproducible lesson materials.
What you can do with it
Homework and lab Hooke's law drills
Students and graders confirm force, spring constant, or displacement for given pairs, with clear rejection when k is negative or a field count is wrong.
Design and game-physics spring checks
Quick structured numbers for spring force under known k and x without standing up a full dynamics or FEA stack.
FAQ
How do I compute spring force with Hooke's law?
The response includes force equal to k times x, plus the full triad and solved set to force.
What happens if the spring constant is negative?
Negative spring constant is not allowed whether you supply k or the solver would compute a negative stiffness from force and displacement.
Can I solve for k or x instead of force?
The solved field names which quantity was found.
Is the Hooke's law calculator free?
The browser tool runs free on your device.
Can force and displacement be negative?
Yes. Both may carry a sign: a negative displacement, such as a compression measured along your axis, gives a negative force in the same sense. Only the spring constant has to be positive.
Related tools
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/mech/hookes-law \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"force":20,"F":1}'const res = await fetch("https://api.kit.forhosting.com/mech/hookes-law", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"force": 20,
"F": 1
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/mech/hookes-law",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"force": 20,
"F": 1
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/mech/hookes-law", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"force":20,"F":1}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"force":20,"F":1}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/mech/hookes-law", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"force": 20,
"F": 1
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "mech.hookes_law",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |
Technical notes
This capacity accepts exactly two of those three quantities as finite numbers, rejects a negative spring constant and malformed input with a clear invalid_input error, and returns the complete F equals k x triad as structured JSON including which field was solved.
What F = kx means and which two quantities you need to send
Delivering force, spring_constant, displacement, solved, formula, and method as JSON makes the result easy to paste into notes, diff in automated tests, or reuse across languages without reimplementing the arithmetic.
How this calculator validates input and applies F = kx
Send a JSON body with exactly two of force, spring_constant, and displacement. Every provided field must be finite: missing all three, only one field, all three at once, empty strings, non-numeric text, NaN, and Infinity all fail immediately with invalid_input before any result is returned, and failed validation is not charged. The spring constant must be strictly positive whether you supply it or the solver computes it as force divided by displacement; a negative spring constant is always rejected as invalid_input, matching the product contract that physical linear stiffness cannot be negative. Results are rounded to a stable decimal precision so the same input always yields the same JSON across JavaScript engines. The same pure function powers the free in-browser tool and the API path.
Practical use, limits, pricing, and delivery channels
Each successful request is one billable item at $0.002; failed validation does not consume balance. Wire the endpoint into mechanics drills, contest answer checkers, spring-lab worksheets, or preprocessing steps where you already prefer explicit domain errors—such as rejecting a negative spring constant—over opaque black-box widgets that cannot explain why a bad input was refused.
Integration use cases
Deterministic fixtures for physics tests
Pipelines that seed unit tests or interactive spring demos can call a pure F=kx oracle instead of reimplementing Hooke's law in every language.
Technical questions
Does this use F = -kx or F = kx?
This product uses the classroom form F equals k x. Apply your own sign convention on force or displacement if you need the restoring-force negative convention.