Rafter count calculator
A 40 ft ridge with rafters every 2 ft needs 42 common rafters, because there are 21 stations including both gable ends and each one takes a pair. Enter ridge length and on-center spacing in the same unit, or count one slope for a shed roof. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Ridge length
- 40
- Rafter spacing
- 2
- Sides
- 2
- Full bays
- 20
- Remainder
- 0
- Rafter positions
- 21
Ordering lumber for a gable roof starts with a simple takeoff question: how many common rafters should you cut? This rafter count calculator answers with a deterministic on-center formula. You provide the ridge length—the building dimension along which rafters are spaced—and the on-center spacing in the same linear units, commonly sixteen or twenty-four inches OC or two-foot centers in feet. The engine places a rafter station at each gable end, fills intermediate positions on the spacing grid, and multiplies by two roof sides by default so each station contributes a pair (one common rafter on each slope). Zero or negative spacing is rejected with a clear invalid input error, which keeps estimating tools honest before stock is reserved.
Measure ridge length and choose consistent on-center spacing
Measure the length of the ridge—or the building eave run that mirrors it—in whatever linear unit your plans use. Rafter spacing is the on-center (OC) distance between successive common rafter positions along that ridge—sixteen inches OC and twenty-four inches OC are residential defaults in many codes, while two-foot centers are common when you work entirely in feet. The calculator accepts any strictly positive finite spacing in the same units as the ridge length.
If you measured forty feet of ridge, send spacing in feet (for example two). If you measured four hundred eighty inches, send spacing in inches (for example sixteen). The engine does not convert units, so mixing feet for length with inches for spacing will invent a nonsense count.
What you can do with it
DIY gable roof lumber lists
Homeowners enter ridge length and sixteen-inch or two-foot OC spacing and know how many common rafters to load before a weekend re-roof or porch build.
Contractor takeoff and bid automation
Estimating tools batch ridge runs from plans, apply gable pair defaults, and emit common-rafter counts for purchase orders without spreadsheets.
FAQ
How does the rafter count calculator count rafters?
Exact multiples use length/spacing + 1; partial bays still count the far end.
What units should I use?
Any consistent linear system. 2). If both are in inches, use 16 or 24 for typical OC. Mixing feet and inches without converting will produce a wrong count.
What if spacing is zero or negative?
Rafter spacing and ridge length must both be strictly positive; zero or negative values are rejected and not charged.
Is the rafter count calculator free?
The browser tool runs free on your device.
Does this include hip, valley, or jack rafters?
No. This tool counts common rafters on a regular OC grid with gable-end stations. Hips, valleys, jacks, ridge boards and collar ties are separate takeoff lines.
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/home/rafter-count \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"ridge_length":40,"rafter_spacing":2}'const res = await fetch("https://api.kit.forhosting.com/home/rafter-count", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"ridge_length": 40,
"rafter_spacing": 2
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/home/rafter-count",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"ridge_length": 40,
"rafter_spacing": 2
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/home/rafter-count", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"ridge_length":40,"rafter_spacing":2}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"ridge_length":40,"rafter_spacing":2}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/home/rafter-count", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"ridge_length": 40,
"rafter_spacing": 2
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "home.rafter_count",
"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
The browser tool runs free on your device; the prepaid API charges $0.002 per successful item when apps and SDKs need the same contract.
Measure ridge length and choose consistent on-center spacing
Send that value as ridge_length; aliases ridge, length, building_length, eave_length and run_length are accepted for form labels that prefer those names. Both fields must be strictly positive finite numbers: zero, negative or non-numeric values raise invalid_input and are not charged. Extremely small or huge values outside the published stability range are also rejected so floating-point bay math stays meaningful on a Worker isolate. Optional aliases for spacing include spacing, oc, on_center, centers and rafter_oc, covering common takeoff spreadsheet headers.
How gable ends, OC bays, and roof sides are counted
When the ridge length is an exact multiple of the spacing, the position count is simply length divided by spacing plus one. When a partial bay remains at the far end, the engine still counts the closing gable-end station, which is equivalent to floor(length divided by spacing) plus two. The layout always includes a rafter station at each gable end of the ridge, then places intermediate stations every rafter_spacing along the run. That yields full_bays, remainder (zero when the end lands on grid), and rafter_positions. By default sides equals two for a simple gable roof: each station needs a pair of common rafters—one on each roof plane—so rafters_needed equals rafter_positions times two. Set sides to one for a single-slope shed roof, or raise it only when your framing standard treats more than two planes as common-rafter stations under the same spacing. rafters_per_side mirrors rafter_positions for estimators who buy or cut one side at a time. The method label is always oc_gable_ends_times_sides for stable downstream branching. Missing required length or spacing, zero or negative dimensions, and sides outside the allowed integer range fail with invalid_input. Identical inputs always produce identical JSON because the path is pure arithmetic with no network, random seed or wall clock.
API usage, pricing, roof takeoff workflows, and practical limits
Call the free in-browser rafter count calculator for quick site estimates, lumber-yard kiosks and contractor whiteboards without installing a spreadsheet. Remember that hip and valley roofs need jack rafters and specials beyond this common-rafter grid—if your material list already includes those lines, keep them separate rather than inflating sides. Send a JSON body with ridge_length and rafter_spacing, plus optional sides when the default gable pair does not match your roof type. Use the prepaid API when a renovation app, quantity-takeoff pipeline, modular home configurator or property-management tool needs a stable contract under KIT balance at $0.002 per successful item; validation failures never consume balance after the engine rejects the request. Pair this endpoint with home.rafter_length when you also need the cut length of each common rafter from span and pitch, or with unit converters when customers mix imperial plans with metric stock lists. Authors shipping SDKs can map rafters_needed straight into purchase orders while showing rafter_positions, full_bays and remainder as explanatory detail for the estimator.
Integration use cases
Lumber yard and ecommerce cut-list tools
Retail sites compute rafter counts as shoppers change building length or OC options, using the same deterministic API contract for quotes and carts.