ForHosting KIT · Developer Utilities

Rafter length from pitch angle and run calculator

This rafter length from pitch and run calculator finds the straight sloped distance from the horizontal run and the roof angle.

● BetaFree · in your browser
Use it from WebAPIEmailTelegramApp soon

Enter a positive run and a pitch angle measured in degrees from the horizontal. The calculator converts the angle to radians, evaluates its cosine, and divides the run by that ratio. The result stays in the same linear unit as the run, so feet produce feet, meters produce meters, and millimeters produce millimeters. It is a focused geometry result for planning and checking, not a substitute for structural design or field measurements.

Measure the horizontal run and pitch angle correctly

The horizontal run is the level distance covered by one rafter, not the sloped board length you are trying to find. On a simple symmetrical gable roof, it is commonly half the building span when measured from the outside wall plate to the ridge centerline, but roof details can change that reference. Measure or derive the run from the same endpoints that the intended rafter segment will connect. Enter that value in any consistent linear unit. The pitch angle is measured upward from a horizontal line, with zero degrees representing a flat member. Do not enter an angle measured from vertical, and do not enter a rise-over-twelve pitch number such as 6 unless you first convert it to degrees. A 6-in-12 pitch is about 26.565 degrees, not 6 degrees. This distinction matters because the cosine calculation expects an actual angular measure. The calculator accepts angles from zero up to, but not including, ninety degrees. A vertical line has no finite rafter length for a positive horizontal run under this model, so ninety degrees is rejected.

Understand the cosine calculation and result

A rafter, its horizontal run, and its vertical rise form a right triangle. Relative to the pitch angle, the run is the adjacent side and the rafter is the hypotenuse. The cosine ratio is adjacent divided by hypotenuse: cosine of the angle equals run divided by rafter length. Rearranging that relationship gives rafter length equals run divided by cosine of the pitch angle. The calculator converts degrees to radians because standard programming cosine functions use radians, calculates the cosine ratio, and performs that division. It returns the converted radian angle and cosine ratio alongside the final sloped length so the work is easy to audit. As the pitch angle increases, cosine decreases and the rafter becomes longer for the same run. At zero degrees, cosine is one, so the rafter length equals the run. Rounding is applied only to the returned fields at the requested precision; the core division uses the full floating-point values. Because the output unit is inherited from the input, label and record your chosen unit separately when using the number in plans.

Use the theoretical length in practical roof planning

The computed value is the geometric straight-line distance between the endpoints represented by your run and angle. That makes it useful for early material estimates, drawing checks, classroom problems, and comparing roof options. Real common rafters may require additional length or layout adjustments for an overhang, ridge-board thickness, birdsmouth seat, plumb cuts, fascia details, connectors, or the way dimensions are referenced on site. Those construction allowances are intentionally not guessed by this calculator. If an overhang has its own horizontal projection, include it in the run only when you want the returned sloped distance to cover that projection and the roof angle remains unchanged. Before cutting material, verify dimensions at the structure and follow the applicable drawings, building rules, and guidance from a qualified professional. For automation, send the run and pitch angle to the API for $0.002 per item; the same deterministic equation will return the same output for identical inputs. Choosing extra decimal places can help intermediate work, but it does not make a measured run or angle more accurate than the original measurement.

Estimate a common rafter segment

Convert a known plate-to-ridge horizontal run and roof angle into the corresponding theoretical sloped distance.

Compare roof pitch options

Keep the run fixed and compare how increasing the pitch angle changes required rafter length.

Check right-triangle drawings

Verify that a drafted roof section uses a hypotenuse consistent with its labeled run and angle.

What formula does the calculator use?

It uses rafter length = horizontal run / cos(pitch angle), with the angle converted from degrees to radians before evaluating cosine.

Which unit should I use?

Use any linear unit consistently. The rafter length is returned in the same unit as the horizontal run.

Can I enter a 6-in-12 pitch as the number 6?

No. The pitch input is an angle in degrees. Convert rise-over-run pitch to degrees first; 6-in-12 is approximately 26.565 degrees.

Does the result include overhangs and cut allowances?

No. It is the pure sloped distance for the supplied horizontal run and angle. Construction details and allowances must be handled separately.

Why must the angle be less than 90 degrees?

At 90 degrees the cosine is zero, so a positive horizontal run cannot produce a finite hypotenuse with this equation.

How much does an API calculation cost?

Each item costs $0.002. The calculation is deterministic and requires no external network service.

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/trig/rafter-length

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/trig/rafter-length \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"run":12,"pitch_angle":30}'
{
  "run": 12,
  "pitch_angle": 30
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "trig.rafter_length",
  "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.

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.

Read the full KIT documentation →