Rafter Calculator
How long each common rafter is, overhang included, how many you need and what length of lumber to buy, for a gable roof at any pitch.
- Checked
- 2 sources
- Formula tested
- Works offline
Results
Rafter
- Wall to ridge (along the slope)
- 13 ft 4 1/8 in
- Overhang tail (along the slope)
- 1 ft 1 3/8 in
- Lumber length to buy
- 16 ft
Roof
- Horizontal run (for IRC span tables)
- 11 ft 11 1/4 in
- Ridge height above the walls
- 6 ft
- Roof angle
- 26.6 °
Count
- Rafters per side
- 31
- Rafters in all (both sides)
- 62
On this page 12 sections
- How do I calculate rafter length?
- Worked example: a 24 ft wide garage at 6/12
- Rafter lengths by building width and pitch
- How many rafters you need
- Rafter size: use the span tables
- The ridge board and the overhang
- Before you cut
- Frequently asked questions
- Guides
- Related calculators
- Sources and method
- Add this calculator to your website
How do I calculate rafter length?
Take half the building width as the run, less half the ridge board's thickness. Multiply the run by the slope factor for your pitch: √(1 + (pitch ÷ 12)²), which is 1.118 for a 6/12 roof. Then add the overhang, multiplied by the same factor. For a 24 ft wide building at 6/12 with a 2x ridge, the run is 11 ft 11 1/4 in and the rafter is 13 ft 4 1/8 in from wall to ridge, or 14 ft 5 5/8 in with a 12 in overhang.
Worked example: a 24 ft wide garage at 6/12
- Run: half of 24 ft is 12 ft. A 2x ridge board is 1½ in thick, so each rafter stops ¾ in short of the center: the run is 11 ft 11 1/4 in.
- Slope factor: for a 6/12 pitch, √(1 + 0.5²) = 1.118. Every foot of run needs 1.118 ft of rafter.
- Wall to ridge: 11.9375 ft × 1.118 = 13 ft 4 1/8 in.
- Overhang: a 12 in level overhang needs 12 × 1.118 = 1 ft 1 3/8 in of rafter tail.
- Total: 14 ft 5 5/8 in. Lumber comes in 2 ft steps, so buy 16 ft boards.
- Count: a 40 ft building at 16 in on center needs 480 ÷ 16 = 30 spaces, plus one, so 31 rafters per side and 62 in all.
Rafter lengths by building width and pitch
Common rafter length with a 12 in level overhang and a 2x ridge board, and the board length to buy in brackets.
| Building width | 4/12 | 6/12 | 8/12 | 10/12 | 12/12 |
|---|---|---|---|---|---|
| 20 ft | 11 ft 6 3/8 in (12) | 12 ft 2 3/4 in (14) | 13 ft 1 3/4 in (14) | 14 ft 2 7/8 in (16) | 15 ft 5 5/8 in (16) |
| 24 ft | 13 ft 7 5/8 in (14) | 14 ft 5 5/8 in (16) | 15 ft 6 5/8 in (16) | 16 ft 10 1/8 in (18) | 18 ft 3 1/2 in (20) |
| 28 ft | 15 ft 9 in (16) | 16 ft 8 3/8 in (18) | 17 ft 11 3/8 in (20) | 19 ft 5 3/8 in (20) | 21 ft 1 1/2 in (22) |
| 30 ft | 16 ft 9 5/8 in (18) | 17 ft 9 7/8 in (20) | 19 ft 1 7/8 in (20) | 20 ft 9 in (22) | 22 ft 6 1/2 in (24) |
| 32 ft | 17 ft 10 1/4 in (20) | 18 ft 11 1/4 in (20) | 20 ft 4 1/4 in (22) | 22 ft 5/8 in (24) | 23 ft 11 1/2 in (26) |
| 36 ft | 19 ft 11 1/2 in (22) | 21 ft 2 1/8 in (22) | 22 ft 9 1/8 in (24) | 24 ft 7 7/8 in (26) | 26 ft 9 3/8 in (28) |
Board lengths step up one size when the rafter is within 3 in of a stock length, to leave room for the plumb cuts. Anything over 20 ft is longer than common stock, so ask your yard.
How many rafters you need
Divide the building length in inches by the spacing, round up, and add one for the end. That gives one side of the roof; double it for a gable roof.
| Building length | 12 in o.c. | 16 in o.c. | 19.2 in o.c. | 24 in o.c. |
|---|---|---|---|---|
| 20 ft | 21 | 16 | 14 | 11 |
| 30 ft | 31 | 24 | 20 | 16 |
| 40 ft | 41 | 31 | 26 | 21 |
| 50 ft | 51 | 39 | 33 | 26 |
| 60 ft | 61 | 46 | 39 | 31 |
Rafters per side. Add rafters for any gable-end overhang (barge) framing, and buy a few spares for crowned or split boards.
Rafter size: use the span tables
This calculator gives the length, not the size. The size (2×6, 2×8, 2×10...) depends on the span, the spacing, the lumber species and grade, and your snow and roof loads. The IRC sets it with rafter span tables, R802.4.1(1) to (8). Those spans are measured horizontally, which is the "horizontal run" figure in the results, not the sloped length.
Look up your run in the table for your loads, or ask your building department which table applies where you live. Snow loads vary a lot by area.
The ridge board and the overhang
- Ridge board: the IRC requires at least 1 in nominal thickness, and no shallower than the cut end of the rafter (R802.3). A 2x ridge (1½ in thick) is common. If the ceiling joists or rafter ties don't tie the walls together, the ridge has to be carried by a wall or by a ridge beam designed by an engineer.
- Overhang: enter it as the level distance from the wall to the end of the tail. Where the rafter is notched over the wall (a birdsmouth), the IRC limits that cantilever to 24 in (R802.7.1.1).
- Slope factor: 4/12 is 1.054, 6/12 is 1.118, 8/12 is 1.202, 10/12 is 1.302 and 12/12 is 1.414. The roof pitch calculator gives it for any pitch.
Before you cut
- Measure the real building width at the top plates, at both ends. Walls aren't always parallel.
- Cut one pattern rafter, test it at both ends of the building, then use it to mark the rest.
- Get a permit for a new roof or addition. Your building department will check the rafter size, spacing and connections.
- Price the roof covering too: the roofing calculator turns the roof area into bundles of shingles.
Frequently asked questions
How long is a rafter for a 24 ft wide building?
How many rafters do I need for a 40 ft roof?
What is the rafter length for a 6/12 pitch?
Is rafter span the same as rafter length?
Does this work for a hip roof?
What length of lumber should I buy?
Guides
Related calculators
Sources and method
- International Code Council: 2021 IRC chapter 8 (roof-ceiling construction) — R802.3 ridge board, R802.4.1 rafter spans measured horizontally, R802.7.1.1 cantilevered rafter tails
- USDA NRCS National Engineering Manual, Timber Construction appendix — dimension lumber standard lengths, 4 to 20 ft in 2 ft steps
Last checked October 12, 2026. How we build and test every calculator: methodology.