Skip to main content
FigureCalc

Truss Calculator

By Uzair Arshad , Senior Civil and Structural Engineer

Last updated: April 27, 2026

Estimate roof truss rafter length, truss count, spacing, and optional cost before you order materials or request a supplier quote. Enter your roof dimensions and this truss calculator handles the geometry. It covers simple gable roof layouts for homeowners, DIY builders, and contractors.

Enter rise in feet or pitch as X in 12

Leave at 0 to skip cost estimate

Leave at 0 to skip labor estimate

How to use this calculator

This truss calculator estimates rafter (top chord) length and truss count for standard gable roof framing. Use it to plan materials before requesting a supplier quote or building your own trusses for a shed, garage, or house.

  1. Choose your calculation mode. Select "Rafter length" if you only need the top chord dimension. Select "Truss count and cost" to also estimate how many trusses you need and get an optional budget number.
  2. Enter your roof run, which is the horizontal distance from the outside wall line to the ridge center. For a symmetric gable, this is half the building span. A common mistake is entering the full building width, which doubles your calculated rafter length.
  3. Pick whether you want to enter rise in feet or pitch as X:12. A 6:12 pitch means 6 inches of rise per 12 inches of run. If you know the total rise to the ridge, use the rise option instead.
  4. For truss count mode, enter your roof length (usually the building length) and planned on center spacing. Most residential roofs use 24 in OC, while heavier loads or longer spans may need 16 in OC.
  5. Add optional cost per truss and labor rate if you want a rough budget estimate. Leave these at zero to skip cost output.
  6. Click "Calculate trusses" for your results.

Pro tip: Always measure horizontal run from the wall plate line to the ridge, not along the sloped roof surface. Measuring the slope gives you a longer number that overestimates rafter length and truss size. Run both 16 in and 24 in spacing through the truss calculator before finalizing your order, because the truss count can jump by 10 units on a 40 ft roof.

Common truss spacing reference

Use this table to pick on center spacing based on your project type. The truss calculator compares your chosen spacing against standard options automatically.

Spacing Typical use Trusses per 40 ft roof
16 in OCHeavy snow loads, longer spans, tile roofs31
24 in OCStandard residential shingle roofs21
48 in OCPole barns, agricultural buildings11

How the calculation works

Geometry:
Rafter length (ft) = √(Run² + Rise²)
Rise (ft) = Run × (Pitch / 12)  when entering pitch
Pitch (X:12) = (Rise / Run) × 12  when entering rise
Roof angle (°) = atan(Rise / Run) × (180 / π)

Truss Count:
Spacing (ft) = Spacing (in) / 12
Truss count = ceil(Roof length / Spacing) + 1

Cost (optional):
Material cost = Truss count × Cost per truss
Labor cost = Hourly rate × Hours
Total cost = Material cost + Labor cost
Run
Horizontal distance from the outside wall to the ridge center (ft)
Rise
Vertical distance from the wall plate to the ridge peak (ft)
Pitch
Roof slope expressed as rise per 12 inches of horizontal run
Roof length
Total length of the roof ridge, usually the building length (ft)
Spacing
On center distance between trusses, typically 16 or 24 inches
Cost per truss
Material price per manufactured truss from the supplier ($)
Hourly rate
Installation labor cost per hour ($)

The truss calculator uses right triangle geometry for rafter (top chord) length and a simple division formula for truss count. Both calculations assume a symmetric gable roof with evenly spaced trusses along the ridge.

Rafter length from rise and run

Rafter length is the hypotenuse of a right triangle formed by the horizontal run and vertical rise.

If you enter a pitch value (such as 6:12), the calculator converts it to rise first: Rise = Run × (Pitch / 12). Then it computes: Rafter length = √(Run² + Rise²).

The roof angle is derived from the same triangle: Roof angle = atan(Rise / Run) × (180 / π).

Truss count from roof length and spacing

The truss calculator converts on center spacing from inches to feet (divide by 12), then divides the total roof length by that spacing. Round up to the next whole number to complete the last bay, then add one for the end truss.

Truss count = ceil(Roof length / Spacing in feet) + 1.

Worked example

Given: 20 ft run, 6:12 pitch, 40 ft roof length, 24 in on center spacing.

  • Rise = 20 × (6 / 12) = 10 ft
  • Rafter length = √(20² + 10²) = √(400 + 100) = √500 = 22.36 ft
  • Roof angle = atan(10 / 20) × (180 / π) = 26.57 degrees
  • Spacing in feet = 24 / 12 = 2 ft
  • Truss count = ceil(40 / 2) + 1 = 20 + 1 = 21 trusses
  • At $150 per truss, material cost = 21 × $150 = $3,150

Typical truss pricing

Standard residential roof trusses cost $100 to $400 each in 2026, depending on span, pitch, and supplier. A 24 ft span common truss runs about $120 to $180, while a 32 ft span may cost $200 to $350. Delivery adds $75 to $200 per load. Enter your local cost per truss into the truss calculator to get a project total.

Quick rule

  • A 6:12 pitch multiplies run by about 1.118 to get rafter length
  • Switching from 24 in to 16 in spacing adds roughly 50% more trusses
  • Full span = run × 2 for a symmetric gable roof

Assumptions and limitations

This truss calculator assumes a straight gable roof with equal pitch on both sides and evenly spaced trusses. It does not account for hip ends, valleys, dormers, or irregular geometry. Rafter length is the diagonal top chord only and does not include overhang, heel height, or tail cuts.

Use this truss calculator for planning and material ordering only. Final truss design, plate connections, load ratings, and spacing must come from the truss manufacturer or a licensed structural engineer. Local building codes may require engineered truss drawings stamped by a professional before installation.

Frequently Asked Questions

How do you calculate a truss?

Measure the horizontal run from the outside wall to the ridge center. Measure or choose a rise value or roof pitch. Calculate the rafter (top chord) length using the Pythagorean theorem: length = √(run² + rise²). A 20 ft run with a 5 ft rise gives √(400 + 25) = 20.62 ft. This covers one side of a symmetric gable truss.

How many trusses do I need?

Divide total roof length by on center spacing in feet, round up to the next whole number, then add one for the end truss. A 40 ft roof at 24 in (2 ft) on center needs ceil(40 / 2) + 1 = 21 trusses. Switching to 16 in spacing raises that to 31 trusses, so compare both before ordering.

How do you calculate the angle of roof trusses?

The roof angle equals the arctangent of rise divided by run. For a 6:12 pitch, angle = atan(6 / 12) × (180 / π) = 26.57 degrees. Steeper pitches like 8:12 give 33.69 degrees. Use this angle for plumb cut layout and to verify your truss drawing matches the intended slope.

How do you calculate trusses for a barn?

Barn trusses follow the same geometry as residential gable trusses. Measure the half-span as your run, pick a pitch (6:12 to 8:12 is common for barns), and calculate rafter length. For truss count, divide building length by 4 ft spacing for pole barns, or 2 ft for standard framing, then add one end truss.

What is the difference between 16 and 24 inch truss spacing?

Trusses at 16 in on center cost more (more units) but carry heavier roof loads, snow, and longer spans. At 24 in on center you use fewer trusses and save on material, but each truss carries more load. On a 40 ft roof, 16 in spacing requires 31 trusses while 24 in needs only 21.

Learn more about roof geometry