ForHosting KIT · Engineering & construction

Roof truss calculator

A gable roof 24 wide at a 6 in 12 pitch, with trusses every 2 along a 40 ridge, needs rafters of about 13.4 from plate to ridge and 21 trusses. Use one unit for every length. Free in your browser.

  • Free
  • Runs in your browser
  • No sign-up
  • Your data stays on your device
Use it from WebAPIEmailTelegramApp soon
If you enter
Span
24
Pitch
6
Spacing
2
Length
40
You get
Pitch label
6/12
Half span
12
Rise
6
Rafter length
13.416407865

A gable roof is two sloping planes that meet at a ridge, framed by a row of triangular trusses that span the building width. Estimators, framers, and DIY builders need two numbers before they order stock: how long each common rafter is, and how many trusses sit along the ridge. This roof truss calculator takes the wall-plate-to-wall-plate span, the pitch as rise per twelve units of run, the on-center truss spacing, and an optional ridge length, then returns the plate-to-ridge rafter length and the truss count. Pitch must be strictly positive; a flat or inverted slope is rejected rather than silently treated as a shed roof.

How rafter length and truss count follow from span, pitch, and spacing

A gable roof is two sloping planes that meet at a ridge, with a row of triangular trusses standing across the building width. Each truss spans from wall plate to wall plate; that full width is the span you send. The common rafter on each side of the ridge is the hypotenuse of a right triangle whose horizontal run is half the span and whose vertical rise follows from pitch.

Pitch is written the way carpenters order stock and read tables: units of rise for every twelve units of run, so six means a six-twelve slope and twelve means a forty-five degree slope. Half the span times pitch divided by twelve is the rise to the ridge line. Along the ridge, trusses are set on-center at the spacing you send.

The building length in that direction is length; when you omit length the calculator treats the plan as square and uses span as the ridge length. The number of bays is the ceiling of length divided by spacing, and the number of trusses is that bay count plus one, so both gable ends receive a truss even when the last bay is shorter than the on-center spacing.

A worked case uses span twenty-four, pitch six, spacing two, and length forty: the run is twelve, the rise is six, the rafter is the square root of one hundred eighty, there are twenty bays, and there are twenty-one trusses. All lengths share one linear unit because the engine never converts feet to metres or inches to millimetres.

Where a roof truss calculator earns its keep

Homeowners meet the same numbers when a shed, porch, or garage needs a lumber list before a weekend install, or when a materials quote must not under-order trusses after the pitch and spacing are fixed by the design. Estimators embed the contract in take-off tools so a schedule of span, pitch, spacing, and length becomes a single pair of results without a spreadsheet full of hidden cells and mixed units.

Product and education tools show learners why doubling the span does not simply double the board length once the pitch factor multiplies the half-span run, and why a forty-foot ridge at two-foot centers needs twenty-one trusses, not twenty. The tool is a simple gable with common rafters and equally spaced trusses, not a hip, valley, gambrel, or scissors truss, and it does not size chords, webs, or snow load.

If you later need only the common rafter with an eave tail, a pitch from rise and run, or a shingle bundle count, treat those as the dedicated roof pages they already are rather than overloading this truss landing.

Rectangular house roofs along the ridge

Add length as the ridge run so a twenty-four-wide by forty-long gable returns twenty-one trusses at two-foot centers, not a square-plan count.

How do I find rafter length and truss count for a gable roof?

Send finite positive span, pitch (rise per 12), and spacing. Optional length is the ridge run (defaults to span).

What happens if span or pitch is zero or negative?

A gable triangle cannot be defined from a non-positive span or pitch, and that failure is not billed.

Does the calculator include eave overhang on the rafter?

Add the along-rafter tail yourself, or use the dedicated rafter-length page when the overhang is the question.

Why are there 21 trusses on a 40 ridge at a spacing of 2?

Because 40 divided by 2 gives 20 bays, and one truss is added so both gable ends are covered. The same rule applies when the last bay is shorter than the spacing.

What does a pitch of 6 mean?

It means 6 units of rise for every 12 units of horizontal run, the way carpenters read pitch. Enter that rise number, not degrees; a pitch of 12 means the roof rises as much as it runs.

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.

POSThttps://api.kit.forhosting.com/build/roof-truss

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.

curl -X POST https://api.kit.forhosting.com/build/roof-truss \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"span":24,"pitch":6,"spacing":2}'
{
  "span": 24,
  "pitch": 6,
  "spacing": 2
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "build.roof_truss",
  "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.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

max_abs1000000000
max_trusses100000
HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

How rafter length and truss count follow from span, pitch, and spacing

Pythagoras then gives the plate-to-ridge rafter length: the square root of half-span squared plus rise squared. That length does not include an eave tail or a birdsmouth seat; it is the geometric common rafter from plate to ridge. Zero or negative span or pitch is rejected as invalid_input because those values cannot define a roof triangle, and a non-positive spacing or length cannot place trusses.

What you send, which units to use, and how validation fails

Send three required numeric fields named span, pitch, and spacing, plus an optional length. When length is omitted the ridge length defaults to span, which is the square-plan shortcut for a shed or garage whose width and ridge run match. Failed tasks are not billed. The same input always produces the same rounded output, which is the contract estimating sheets, framing tickets, and edge workers rely on when they pin a twenty-four by forty roof as a thirteen-point-four rafter and twenty-one trusses. Span is the wall-plate-to-wall-plate width in any linear unit; aliases roof_span, building_span, width, and S are accepted so a form that already says width does not need a rename. Pitch is the rise component of an X-over-twelve pitch, never degrees and never a unitless slope alone; aliases roof_pitch, pitch_rise, and X are accepted. Spacing is the on-center distance between adjacent trusses in the same unit as span; aliases truss_spacing, on_center, oc, and centres are accepted. Length is the building length along the ridge; aliases building_length, roof_length, and ridge_length are accepted. Strings that parse as finite numbers are accepted the same as JSON numbers. On success the response echoes the cleaned span, pitch, spacing, and length, publishes pitch_label such as six slash twelve, half_span as the run from ridge to plate, rise as the vertical height of that triangle, rafter_length as the plate-to-ridge hypotenuse, bay_count as the number of spaces between trusses, truss_count as bay_count plus one, and formula as the identity that produced them. A span of zero, a negative pitch, a missing field, or a non-finite value fails with invalid_input naming the field so a form can highlight that control. Successful API calls use the published base of $0.002 per item. Upper limits are generous finite lengths; truss_count is capped so a tiny spacing cannot explode into an unusable list.

Where a roof truss calculator earns its keep

Framers and small contractors turn a measured span, a chosen pitch, and an on-center spacing into a shopping list before they leave the yard: rafter stock from rafter_length, and a truss order from truss_count, with waste, hangers, and ridge thickness added after the pure geometry is known. On this page the work runs entirely in your browser; through the API each successful lookup costs $0.002, failed validation is not charged, and nothing is stored after the response returns. That split — free interactive exploration and a priced, identical API — matches the rest of the KIT tier-A catalog and lets you move from a phone check on site to an automated pipeline without changing the mathematical result.

Gable garage and shed take-offs

Send the wall-plate span, the 6/12 (or other) pitch, and on-center spacing; use rafter_length for stock and truss_count for the truss order.

Estimating software and framing tickets

Pin span, pitch, spacing, and length in a job ticket; the API returns the same rounded rafter_length and truss_count the public widget showed.

How is the number of trusses counted?

Trusses sit on-center along the ridge. bay_count is ceil(length/spacing) and truss_count is bay_count plus one, so both gable ends receive a truss even when the last bay is short.

What does the roof truss calculator cost?

The browser tool is free. API requests use prepaid KIT balance at $0.002 per successful call; invalid input is not billed.

Read the full KIT documentation →