Skip to content

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.

Rafter Calculator Results update as you type
Roof
Outside of one wall's top plate to the outside of the other. The rafters run from each wall up to the ridge in the middle.
in 12
Inches of rise per 12 in of run. 6 means a 6/12 roof. The roof pitch calculator works it out from two measurements.
How far the eave sticks out past the wall, measured horizontally. Enter 0 for no overhang.
Each rafter stops at the face of the ridge board, so half its thickness comes off each side's run.
How many rafters
How many rafters

Results

Rafter length with overhang 14 ft 5 5/8 in 6/12 pitch, 31 rafters per side.

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
  1. How do I calculate rafter length?
  2. Worked example: a 24 ft wide garage at 6/12
  3. Rafter lengths by building width and pitch
  4. How many rafters you need
  5. Rafter size: use the span tables
  6. The ridge board and the overhang
  7. Before you cut
  8. Frequently asked questions
  9. Guides
  10. Related calculators
  11. Sources and method
  12. 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

Half of a 6/12 gable roof in side view, drawn to scale. A rafter runs from the ridge board down past the wall to a 12 inch overhang. The level run from the wall to the ridge is 11 feet 11 and a quarter inches, the rise is 6 feet, and the rafter is 14 feet 5 and five-eighths inches long including the overhang. Rafter = (run + overhang) × slope factor run 11 ft 11 1/4 in rise 6 ft rafter 14 ft 5 5/8 in overhang wall ridge board
  1. 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.
  2. Slope factor: for a 6/12 pitch, √(1 + 0.5²) = 1.118. Every foot of run needs 1.118 ft of rafter.
  3. Wall to ridge: 11.9375 ft × 1.118 = 13 ft 4 1/8 in.
  4. Overhang: a 12 in level overhang needs 12 × 1.118 = 1 ft 1 3/8 in of rafter tail.
  5. Total: 14 ft 5 5/8 in. Lumber comes in 2 ft steps, so buy 16 ft boards.
  6. 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 width4/126/128/1210/1212/12
20 ft11 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 ft13 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 ft15 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 ft16 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 ft17 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 ft19 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 length12 in o.c.16 in o.c.19.2 in o.c.24 in o.c.
20 ft21161411
30 ft31242016
40 ft41312621
50 ft51393326
60 ft61463931

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?
At 6/12 with a 2x ridge, 13 ft 4 1/8 in from wall to ridge, or 14 ft 5 5/8 in with a 12 in overhang. Buy 16 ft boards. At 4/12 it is 13 ft 7 5/8 in with the same overhang.
How many rafters do I need for a 40 ft roof?
At 16 in on center, 31 per side, or 62 for a gable roof. At 24 in on center, 21 per side, or 42 in all.
What is the rafter length for a 6/12 pitch?
1.118 ft of rafter for every foot of run, which is 13.42 in per 12 in of run. Multiply your run (half the building width) by 1.118, then add the overhang times 1.118.
Is rafter span the same as rafter length?
No. The IRC measures rafter span horizontally, from the wall to the ridge (R802.4.1). The rafter itself is longer, because it runs along the slope. Use the horizontal run when you look up the span tables.
Does this work for a hip roof?
For the common rafters, yes: they are the same length as on a gable roof of the same width and pitch. Hip and valley rafters and jack rafters are different lengths, and this calculator doesn't work those out.
What length of lumber should I buy?
The next even length above the rafter, since lumber comes in 2 ft steps. The calculator steps up one more size when a rafter is within 3 in of a stock length, so there is room for the cuts at each end.

Guides

Sources and method

Last checked October 12, 2026. How we build and test every calculator: methodology.

Add this calculator to your website

Free for any site: paste this code into a page and the calculator appears there, always up to date. No sign-up. It works on phones and resizes itself.

All embeddable calculators