CSS Spring Physics Generator
Model a damped spring and approximate its motion with a CSS cubic-bezier().
Examples
Critically damped spring
generateSpring({ stiffness: 100, damping: 20, mass: 1, velocity: 0 })dampingRatio: 1, duration ≈ 1.06s, bezier: cubic-bezier(0.25, ...)Damping of 2*sqrt(100*1) hits zeta 1, so the response rises monotonically to its target with no overshoot.
Overdamped spring
generateSpring({ stiffness: 100, damping: 100, mass: 1, velocity: 0 })dampingRatio: 5, slower settle, small bezier errorA damping ratio above 1 follows the two-exponential path and creeps toward the target without oscillating.
About this tool
CSS Spring Physics Generator models a mass/spring/damper system with springValue(time, parameters): stiffness, damping, mass, and initial velocity feed the analytic response — underdamped oscillation below zeta 1, the critically damped closed form at zeta 1, and the two-exponential overdamped form above it — while generateSpring(parameters) wraps the result with its dampingRatio, a settleTime duration, normalized samples, and a cubic-bezier approximation.
Settling is defined as the first instant after which the response stays within 1% of its target with low velocity: settleTime(parameters) scans forward with a step of min(0.01, 1 / (wn * 80)) over a horizon of max(2, 12 / zeta / wn), so stiffer springs at a fixed damping ratio settle sooner. Stiffness and mass clamp to small positive floors, so zero or negative inputs degrade gracefully instead of producing NaN.
The easing bridge is approximateCubicBezier(samples): interior samples (0 < t < 1) fit y1/y2 by deterministic coordinate descent with fixed x1 0.25 and x2 0.75, endpoints [0,0]/[1,1] are implied rather than fitted, and the result carries its mean-square error plus a ready-to-paste cubic-bezier(...) string.
How to use this tool
Enter spring parameters
Set stiffness, damping, mass, and velocity — a damping ratio of 1 (damping = 2 * sqrt(stiffness * mass)) gives the critically damped, oscillation-free response.
Read duration and damping ratio
generateSpring returns duration from settleTime and the dampingRatio, so you know exactly how long the motion lasts and whether it overshoots.
Copy the bezier easing
Paste the bezier css field (cubic-bezier(0.25, y1, 0.75, y2)) into your transition, and check error to see how closely the curve tracks the true spring.
Tune stiffness for speed
Raise stiffness while holding the damping ratio at 1 to shorten the settle time without introducing oscillation.
Use cases
Designing UI motion curves
Convert stiffness/damping/mass triples into cubic-bezier easings that feel physical in buttons, sheets, and dialogs.
Eliminating overshoot
Dial the parameters to zeta 1 and confirm the sampled response never exceeds its target before shipping the easing.
Budgeting animation duration
Use the settleTime duration as the transition length so motion finishes exactly when the spring has visibly settled.
Common mistakes
Mistake:Passing zero or negative stiffness and expecting an error.
Fix:Stiffness clamps to a small positive floor (0.1 in generateSpring, 0.0001 in springValue) — the tool returns a very slow spring, not a rejection, so validate inputs yourself if negatives must be blocked.
Mistake:Assuming the bezier output reproduces spring overshoot.
Fix:A single cubic-bezier segment cannot overshoot its endpoints; underdamped springs carry a nonzero fit error — keep the oscillation in JS or accept the smoothed easing.
Mistake:Expecting higher stiffness alone to always settle faster.
Fix:Settle time depends on zeta * wn together; raise stiffness while scaling damping to hold the damping ratio constant, otherwise the ratio drops and ringing returns.
Frequently asked questions
What does this tool do?
It models a mass/spring/damper system from your stiffness, damping, mass, and velocity — reporting the damping ratio, the settleTime duration, normalized response samples, and a ready-to-paste cubic-bezier easing fitted to the true spring curve.
How do I get motion with no oscillation?
Aim for a damping ratio of 1 by setting damping to 2 * sqrt(stiffness * mass) — for example stiffness 100, damping 20, mass 1. The critically damped response rises monotonically and never exceeds its target.
Is my spring configuration uploaded or stored?
No. The analytic response, settle-time scan, and bezier fit are pure client-side math — your parameters never leave your browser.
Why doesn't the bezier output overshoot like my spring?
A single cubic-bezier segment is pinned to its [0,0]/[1,1] endpoints and cannot overshoot, so underdamped springs carry a nonzero fit error. Use the easing for the smoothed feel, or drive the raw springValue samples from JavaScript when the bounce matters.
Related guides
References & standards
Related tools
Aspect Ratio Calculator
Calculate dimensions and ratios for images and videos.
Border Radius Generator
Visually craft CSS border-radius values — including the advanced 8-value slash syntax for organic blob shapes — with a live preview and one-click copy.
Box Shadow Generator
Visual CSS box-shadow generator. Create beautiful shadows with live preview and copy the CSS code.
CSS Grid Generator
Visually build CSS Grid layouts — set columns, rows and gaps, see a live preview, and copy production-ready grid-template CSS.
Cubic Bezier / Easing Generator
Build a CSS cubic-bezier() timing function visually — drag control points, preview common presets, see the easing curve live, and copy the transition-timing-function CSS.
Dummy Avatar Generator
Generate unique SVG avatars for mockups and placeholders using various illustration styles