# Spring Calculator (Compression, Extension, Torsion Design) (`jumblemog/spring-calculator`) Actor

Helical spring calculator from plain text: rate, stress, safety factors, solid and free length, buckling, surge and fatigue for compression, extension and torsion springs, and compression spring design from loads and space.

- **URL**: https://apify.com/jumblemog/spring-calculator.md
- **Developed by:** [Jumble Mog](https://apify.com/jumblemog) (community)
- **Categories:** AI, Automation, Developer tools
- **Security:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per event

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Spring Calculator (Compression, Extension, Torsion Design)

**Size or check a coil spring from one line of text.** Type `design a compression spring: 200 N at 40 mm, 100 N at 50 mm, fits in a 25 mm hole` or `music wire 2 mm, OD 20 mm, 10 total coils, squared and ground, free length 60 mm, 150 N at 40 mm`. You get back:

- **The rate** and the **stress and safety factor at every load**, with the Bergsträsser (or Wahl) curvature correction.
- **The lengths**: free, solid, pitch, and the longest free length that can be closed solid without taking a set.
- **The checks**: safety when closed solid, buckling, surge frequency, overrun to solid, and fatigue (Gerber with Zimmerli data) when there are two loads.
- **The wire strength** for the actual wire size (Sut = A/d^m) and the allowable stress for the material, set removal and shot peening.
- **For design requests**: every standard wire size is tried at spring indexes 4 to 12, and the lightest spring that meets the loads, space, solid safety, buckling and fatigue margins comes back, with the other sizes that work.
- **A chart**: the load line with each load point, next to each stress as a share of its allowable.

It covers three kinds of helical spring:

- **Compression**: analyze or design. Plain, plain and ground, squared, or squared and ground ends.
- **Extension**: rate, initial tension (and whether it can be wound in), body stress and the hook bending and torsion stresses.
- **Torsion**: rate per turn and per degree (legs included), bending stress, and how far the coil closes down on its arbor.

Seven wires: music wire (A228), oil-tempered (A229), hard-drawn (A227), chrome-vanadium (A232), chrome-silicon (A401), 302 stainless (A313) and phosphor bronze (B159). Millimetres and newtons, or inches and pounds: results come back in the units you wrote.

It's made for:

- Mechanical and product designers sizing a spring before ordering samples.
- Makers, repair shops and students checking a spring they already have.
- AI agents that need real spring numbers instead of a guess.

![A compression spring designed by this Actor for 200 N at 40 mm and 100 N at 50 mm inside a 25 mm hole: 2.8 mm music wire, the load line from free to solid with both load points, and the stresses at 61% and 30% of the allowable at the two loads and 81% when closed solid](https://api.apify.com/v2/key-value-stores/Km5b4PG3kYHdZSb1E/records/spring-calculator-example.png?signature=IsmHmcNMPmDvTrYIUslJ)

### How to use it

1. Write **Springs**, one per entry. The form has examples.
2. Optionally set the **Default material** and the **Units** for numbers written without one.
3. Click **Start**. Each spring is a row in the results, with its summary, chart and report.

#### Writing a spring

| You write | It means |
|---|---|
| `music wire 2 mm`, `2 mm chrome-silicon wire`, `d = 0.08 in` | the wire and material |
| `OD 20 mm`, `ID 16 mm`, `mean diameter 18 mm` | the coil size |
| `10 total coils`, `8 active coils`, `20 body coils`, `6 body turns` | the coils |
| `squared and ground`, `plain ends`, `squared` | compression ends |
| `free length 60 mm` | free length |
| `150 N at 40 mm`, `compressed to 45 mm`, `10 mm deflection`, `20 lbf` | loads |
| `initial tension 12 N` | extension springs |
| `450 N·mm`, `90°`, `legs 25 mm` | torsion springs |
| `set removed`, `shot peened`, `cyclic` | allowable stress and fatigue |
| `design ...`, `fits in a 25 mm hole`, `over a 10 mm rod`, `max free length 80 mm`, `rate 10 N/mm` | design a compression spring |

Objects work too; see Input.

### Examples

All of these ran on this Actor; the numbers are from the results.

| Spring | Result |
|---|---|
| `music wire 0.037 in, OD 0.4375 in, 12.5 total coils, squared and ground` (Shigley Example 10-2) | Rate 4.115 lbf/in, solid 0.4625 in; a free length up to 2.026 in can close solid without a set (the book: 4.116 lbf/in and 2.03 in) |
| `design a compression spring: 200 N at 40 mm, 100 N at 50 mm, fits in a 25 mm hole, music wire, cyclic` | 2.8 mm wire, OD 21.28 mm, 9.9 active / 11.9 total coils, free length 60.08 mm, rate 9.96 N/mm; safety 1.65 at 200 N, 1.24 at solid, fatigue 1.57. 3.0 mm wire also works |
| `extension spring, hard-drawn 1.5 mm wire, OD 12 mm, 20 body coils, initial tension 12 N, 40 N` | Rate 2.143 N/mm, free length 49.5 mm; at 40 N the hook bending is the weakest spot, safety 1.67 |
| `torsion spring, music wire 1.5 mm, OD 15 mm, 6 body turns, legs 25 mm, 450 N·mm` | 1086 N·mm/turn; 450 N·mm winds it 149°, 1481 MPa, safety 1.10; the inside diameter closes to 11.13 mm |
| Valve spring: chrome-silicon 4 mm, OD 30 mm, 8 total coils, shot peened, 300 N at 50 mm and 40 mm | Free length 62.81 mm, rate 23.43 N/mm, fatigue safety 1.59, but closed solid it passes the allowable (safety 0.94): a warning says so |

The tests check that:

- Shigley's Example 10-2 comes out: Sut 323.6 kpsi, rate 4.116 lbf/in, free length 2.03 in.
- Rates, extension free lengths, torsion stresses and equivalent turns match their formulas.
- Design results fit the hole, meet the rate, keep the solid safety and come back lightest first; an impossible design says why.
- The text forms above are read correctly, including US units only when a number carries them.

### How-to examples

Each example is a complete input; the results are from runs of the Actor (also listed under **Examples**).

#### How to design a compression spring for two loads and a hole

```json
{"springs": ["design a compression spring: 200 N at 40 mm, 100 N at 50 mm, fits in a 25 mm hole, music wire, cyclic"]}
```

Result: 2.8 mm wire, OD 21.28 mm, 9.9 active and 11.9 total coils, free length 60.08 mm, rate 9.96 N/mm; safety 1.65 at 200 N, 1.24 at solid, fatigue 1.57. A 3.0 mm wire also works.

#### How to calculate a spring's rate and solid length

```json
{"springs": ["music wire 0.037 in, OD 0.4375 in, 12.5 total coils, squared and ground"]}
```

Result: this is Shigley's Example 10-2: rate 4.115 lbf/in and solid length 0.4625 in; a free length up to 2.026 in can close solid without taking a set (the book: 4.116 lbf/in and 2.03 in).

#### How to check a torsion spring

```json
{"springs": ["torsion spring, music wire 1.5 mm, OD 15 mm, 6 body turns, legs 25 mm, 450 N·mm"]}
```

Result: 1086 N·mm per turn; 450 N·mm winds it 149° at 1481 MPa, safety 1.10, and the inside diameter closes to 11.13 mm.

#### How to let an AI agent size springs

Add this Actor to the [Apify MCP server](https://mcp.apify.com) with `https://mcp.apify.com/?tools=jumblemog/spring-calculator`. The agent describes the spring or the loads and space in one line and answers with the wire, coils, free length and safety factors.

### FAQ

**Which springs does it handle?** Round-wire helical compression, extension and torsion springs. The design search covers compression springs; extension and torsion springs are checked from their wire and coil size.

**Which materials are built in?** Seven wires: music wire (A228), oil-tempered (A229), hard-drawn (A227), chrome-vanadium (A232), chrome-silicon (A401), 302 stainless (A313) and phosphor bronze (B159).

**Does it check fatigue and buckling?** Yes: fatigue by Gerber against Zimmerli's endurance data (unpeened or shot peened), buckling, and the surge frequency.

**Are the results ready to order?** They're engineering estimates; confirm critical springs with the maker and a test.

### Input

| Field | What it is |
|---|---|
| `springs` | Springs, as text or objects. |
| `material` | Default wire for springs that don't name one (music wire if unset). |
| `units` | `mm` (default) or `in`, for numbers written without a unit. |
| `charts` | Draw charts (default on). |

**A spring as an object** takes:

- `type`: `compression` (default), `extension` or `torsion`; `mode`: `analyze` or `design`.
- `material`, `wire`, and one of `od`, `id` or `meanDiameter`.
- `activeCoils`, `totalCoils` or `bodyCoils`; `ends`; `freeLength`.
- `loads`: a list of objects with `force`, `length`, `deflection`, `moment` or `angle`.
- Design: `rate`, `holeDiameter`, `rodDiameter`, `maxFreeLength`, `maxSolidLength`, `minSafety` (1.2), `minFatigueSafety` (1.5).
- `setRemoved`, `peened`, `cyclic`, `endSupport` (`fixed`, `pinned`, `fixed-pinned`, `free`), `initialTension`, `legs`, `units`, `title`.
- `text`: a line of text, with the other fields overriding what it says.

### Output

One dataset item per spring, also saved together in the run's `OUTPUT` record:

```json
{
  "request": 2, "status": "ok", "type": "compression", "mode": "design",
  "title": "Designed compression spring, music wire",
  "units": {"length": "mm", "force": "N", "stress": "MPa", "rate": "N/mm"},
  "spring": {"material": "Music wire", "astm": "A228", "wireDiameter": 2.8, "outsideDiameter": 21.28,
             "springIndex": 6.6, "activeCoils": 9.9, "totalCoils": 11.9, "ends": "squared and ground",
             "freeLength": 60.0791, "solidLength": 33.32, "pitch": 5.5029, "massGrams": 33.394},
  "rate": 9.96061,
  "material": {"sut": 1904.37, "allowableShear": 856.97},
  "points": [{"force": 200.0, "length": 40.0, "deflection": 20.0791, "stress": 520.36, "safety": 1.647},
             {"force": 100.3939, "length": 50.0, "deflection": 10.0791, "stress": 261.2, "safety": 3.281}],
  "solid": {"force": 266.5369, "stress": 693.47, "safety": 1.236},
  "fatigue": {"alternating": 129.58, "mean": 390.78, "allowableAlternating": 203.29, "safety": 1.569},
  "alternatives": [{"wireDiameter": 3.0, "outsideDiameter": 23.7, "activeCoils": 9.2, "solidSafety": 1.366, "...": "..."}],
  "imageUrl": "https://api.apify.com/v2/key-value-stores/.../records/002-....png"
}
```

Extension springs add `initialTension` and the hook stresses at each load; torsion springs give `ratePerTurn`, `ratePerDegree` and the moment, angle and inside diameter at each load. Every item has `warnings`, `notes` (the formulas and assumptions), a Markdown `report` and links to the chart and report. A request that can't be computed has `"status": "failed"` and the reason in `error`, and isn't billed.

### How it works

1. **Reading**: each line is read for the wire, coil size, coils, ends, loads and design needs; numbers carry their units.
2. **Wire strength**: Sut = A/d^m with the constants for the material and size range; E and G by size.
3. **Allowables**: torsion as a share of Sut for compression and extension bodies (set removed or not), hook bending and torsion for extension springs, bending for torsion springs (Shigley Tables 10-6 and 10-7, eq. 10-57).
4. **Analysis**: rate k = d⁴G/(8D³Na), stress τ = K_B·8FD/(πd³), the solid and free lengths from the end type, buckling at 2.63·D/α, surge frequency, and fatigue by Gerber against Zimmerli's endurance data.
5. **Design**: for each standard wire size, spring indexes 4 to 12 set the coil diameter and active coils for the rate; springs that fit the space with 15% overrun to solid, solid safety 1.2, no buckling and (if cyclic) fatigue safety 1.5 are kept, lightest first.

Results are engineering estimates; confirm critical springs with the maker and a test.

### Pricing

You pay one low price per spring, at the price shown on this page. It includes the chart and the report. Requests that can't be computed are never charged. If you set a maximum cost per run, the Actor stops before a request that wouldn't fit.

### Speed

A spring takes a few milliseconds and a design search well under a second, plus the chart. A run through the API answers in about 5 to 10 seconds, including the cloud container starting.

### Tips and limits

- **Round-wire helical springs** only: no conical, barrel, flat, wave or disc springs, and no square wire.
- **Design search** covers compression springs; for extension and torsion springs give the wire and coil size and it checks them.
- **Static allowables** assume room temperature. Hot springs relax: derate them, or use chrome-silicon or stainless.
- **Fatigue** uses Zimmerli's data for steel wire under 10 mm (unpeened or shot peened), which is conservative for most spring steels; it isn't applied to phosphor bronze limits.
- **Extension hooks** are full loops with the bend radius at B taken as 2d unless your maker says otherwise.
- **Limits**: 500 springs per run.

### For AI agents and developers

This Actor works with the [Apify MCP server](https://mcp.apify.com), so AI agents can call it as a tool. Pass `springs` as plain text and read `summary`, `rate`, `points[].safety`, `solid.safety`, `fatigue.safety`, `warnings` and, for designs, `spring` and `alternatives`. A direct API call that waits for the answer:

```bash
curl -X POST "https://api.apify.com/v2/acts/jumblemog~spring-calculator/run-sync-get-dataset-items?token=YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"springs": ["design a compression spring: 50 N at 30 mm, 20 N at 40 mm, over a 6 mm rod, stainless"]}'
```

`run-sync` instead returns the run's `OUTPUT`: the status, the counts and every result as JSON.

In Python, with the `apify-client` package:

```python
from apify_client import ApifyClient

client = ApifyClient("YOUR_TOKEN")
run = client.actor("jumblemog/spring-calculator").call(run_input={
    "springs": [{"material": "chrome-silicon", "wire": "4 mm", "od": "30 mm", "totalCoils": 8,
                 "ends": "squared and ground", "peened": True,
                 "loads": [{"force": "300 N", "length": "50 mm"}, {"length": "40 mm"}]}],
})
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item["summary"])
```

### Credits

- Charts: [Vega-Lite](https://vega.github.io/vega-lite/) and [vl-convert](https://github.com/vega/vl-convert) (BSD-3-Clause), with the [Inter](https://rsms.me/inter/) font (SIL Open Font License).
- Method: Budynas and Nisbett, *Shigley's Mechanical Engineering Design*, chapter 10 (spring rate, curvature factors, wire strength constants, allowables, buckling, surge and Zimmerli fatigue data), which summarizes the ASTM A227, A228, A229, A232, A401, A313 and B159 wire standards and Spring Manufacturers Institute practice.

# Actor input Schema

## `springs` (type: `array`):

One spring per entry, as a line of text or an object. Analyze: give the wire, the coil size (od, id or meanDiameter), the coils and the loads ('150 N at 40 mm', 'compressed to 45 mm', '10 mm deflection', '450 N·mm', '90°'). Design (compression): give two forces at two lengths, or a rate and a force, plus the space ('fits in a 25 mm hole', 'over a 10 mm rod', 'max free length 80 mm'), and the lightest standard wire size that works comes back. Materials: music wire, oil-tempered, hard-drawn, chrome-vanadium, chrome-silicon, 302 stainless, phosphor bronze. Object fields: type (compression, extension, torsion), mode (analyze, design), material, wire, od/id/meanDiameter, activeCoils/totalCoils/bodyCoils, ends, freeLength, loads (objects with force, length, deflection, moment or angle), rate, holeDiameter, rodDiameter, maxFreeLength, maxSolidLength, setRemoved, peened, cyclic, endSupport, initialTension, legs, units, title.

## `material` (type: `string`):

For springs that don't name one.

## `units` (type: `string`):

For numbers written without a unit. Results come back in the units the spring is written in.

## `charts` (type: `boolean`):

The load line with each load point, and each stress as a share of its allowable.

## Actor input object example

```json
{
  "springs": [
    "music wire 0.037 in, OD 0.4375 in, 12.5 total coils, squared and ground",
    "design a compression spring: 200 N at 40 mm, 100 N at 50 mm, fits in a 25 mm hole, music wire, cyclic",
    "extension spring, hard-drawn 1.5 mm wire, OD 12 mm, 20 body coils, initial tension 12 N, 40 N",
    "torsion spring, music wire 1.5 mm, OD 15 mm, 6 body turns, legs 25 mm, 450 N·mm",
    {
      "title": "Valve spring",
      "material": "chrome-silicon",
      "wire": "4 mm",
      "od": "30 mm",
      "totalCoils": 8,
      "ends": "squared and ground",
      "peened": true,
      "loads": [
        {
          "force": "300 N",
          "length": "50 mm"
        },
        {
          "length": "40 mm"
        }
      ]
    }
  ],
  "material": "music",
  "units": "mm",
  "charts": true
}
```

# Actor output Schema

## `results` (type: `string`):

One row per spring: the summary and chart.

## `output` (type: `string`):

The OUTPUT record: every result in one JSON object.

## `files` (type: `string`):

Charts (PNG and SVG) and Markdown reports in the run's key-value store.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "springs": [
        "music wire 0.037 in, OD 0.4375 in, 12.5 total coils, squared and ground",
        "design a compression spring: 200 N at 40 mm, 100 N at 50 mm, fits in a 25 mm hole, music wire, cyclic",
        "extension spring, hard-drawn 1.5 mm wire, OD 12 mm, 20 body coils, initial tension 12 N, 40 N",
        "torsion spring, music wire 1.5 mm, OD 15 mm, 6 body turns, legs 25 mm, 450 N·mm",
        {
            "title": "Valve spring",
            "material": "chrome-silicon",
            "wire": "4 mm",
            "od": "30 mm",
            "totalCoils": 8,
            "ends": "squared and ground",
            "peened": true,
            "loads": [
                {
                    "force": "300 N",
                    "length": "50 mm"
                },
                {
                    "length": "40 mm"
                }
            ]
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("jumblemog/spring-calculator").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "springs": [
        "music wire 0.037 in, OD 0.4375 in, 12.5 total coils, squared and ground",
        "design a compression spring: 200 N at 40 mm, 100 N at 50 mm, fits in a 25 mm hole, music wire, cyclic",
        "extension spring, hard-drawn 1.5 mm wire, OD 12 mm, 20 body coils, initial tension 12 N, 40 N",
        "torsion spring, music wire 1.5 mm, OD 15 mm, 6 body turns, legs 25 mm, 450 N·mm",
        {
            "title": "Valve spring",
            "material": "chrome-silicon",
            "wire": "4 mm",
            "od": "30 mm",
            "totalCoils": 8,
            "ends": "squared and ground",
            "peened": True,
            "loads": [
                {
                    "force": "300 N",
                    "length": "50 mm",
                },
                { "length": "40 mm" },
            ],
        },
    ] }

# Run the Actor and wait for it to finish
run = client.actor("jumblemog/spring-calculator").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "springs": [
    "music wire 0.037 in, OD 0.4375 in, 12.5 total coils, squared and ground",
    "design a compression spring: 200 N at 40 mm, 100 N at 50 mm, fits in a 25 mm hole, music wire, cyclic",
    "extension spring, hard-drawn 1.5 mm wire, OD 12 mm, 20 body coils, initial tension 12 N, 40 N",
    "torsion spring, music wire 1.5 mm, OD 15 mm, 6 body turns, legs 25 mm, 450 N·mm",
    {
      "title": "Valve spring",
      "material": "chrome-silicon",
      "wire": "4 mm",
      "od": "30 mm",
      "totalCoils": 8,
      "ends": "squared and ground",
      "peened": true,
      "loads": [
        {
          "force": "300 N",
          "length": "50 mm"
        },
        {
          "length": "40 mm"
        }
      ]
    }
  ]
}' |
apify call jumblemog/spring-calculator --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,jumblemog/spring-calculator"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/tCmtP8GxKHRkdunBX/builds/H5GbgzA76PdBKhCwN/openapi.json
