Calculate how many posts, rails, pickets, or prefab panels you need to build a fence, plus total material cost, from your fence length and post spacing.
Fence Formula
The calculator works in three modes. Each mode starts by dividing the fence into sections and counting posts, then adds the materials specific to that mode.
S = ceil((L - G) / s)
Posts = S + 1 (open run) or Posts = S (closed perimeter)
Rails = ceil(S * r * (1 + w/100))
Pickets = ceil(((L - G) * 12 / (p + g)) * (1 + w/100))
Panels = ceil(((L - G) / W) * (1 + w/100))
- S = number of fence sections (always rounded up)
- L = total fence length
- G = combined width of gate openings
- s = maximum post spacing (center to center)
- r = rails per section
- p = picket or board width (inches)
- g = gap between pickets (inches)
- W = prefab panel width
- w = waste allowance percentage
The section count divides the infill length (total length minus any gate openings) by your maximum post spacing and rounds up, so the real span never exceeds the limit you set. Post count adds one to the section count for an open run because a straight line of fence needs an end post on both ends; a closed perimeter reuses the corner posts, so the count equals the section count. Rails multiply the section count by the rails per section. Pickets divide the infill length by the coverage of one picket plus its gap. Panels divide the infill length by one panel width. The waste allowance multiplies rails, pickets, and panels (not posts) so you buy a few spares for cuts and defects.
Typical Post Spacing and Picket Coverage
Use these common values when you are not working from a specific product spec.
| Fence type | Typical max post spacing |
|---|---|
| Wood privacy or picket | 6 to 8 ft |
| Prefab vinyl or wood panels | 6 to 8 ft (panel width) |
| Chain link | up to 10 ft |
| Split rail | 8 to 11 ft (rail length) |
| Board | Actual width | Coverage with 0 in gap |
|---|---|---|
| 1x4 picket | 3.5 in | 3.5 in |
| 1x6 picket | 5.5 in | 5.5 in |
| 1x6 with 0.5 in gap | 5.5 in | 6.0 in |
Example Problems
Example 1: Wood fence, open run. You are building a 100 ft straight wood fence with a maximum post spacing of 8 ft, 3 rails per section, 5.5 in pickets, no gap, no gate, and a 10 percent waste allowance. Sections = ceil(100 / 8) = 13. Posts = 13 + 1 = 14. Rails = ceil(13 * 3 * 1.10) = ceil(42.9) = 43. Pickets = ceil((100 * 12 / 5.5) * 1.10) = ceil(240) = 240.
Example 2: Prefab panels, closed perimeter. You are enclosing a 120 ft perimeter with 8 ft panels and no gate. Sections = ceil(120 / 8) = 15. Because it is a closed loop, Posts = 15. Panels = ceil(120 / 8) = 15.
Frequently Asked Questions
Why does an open run need one more post than a closed perimeter? A straight line of fence has two ends, and each end needs its own post, so the post count is the section count plus one. A closed perimeter loops back on itself and shares the corner and end posts, so the post count equals the section count.
How much waste should I add? A 10 percent allowance is a common default. It covers miscuts, warped or split boards, and the occasional measuring error. The allowance is applied to rails, pickets, and panels, not to posts, since posts are counted exactly from the section layout.
How are gates handled? Each gate opening is subtracted from the infill length before the sections are counted and is then treated as its own section. The calculator does not include gate framing or hardware, since those depend on the gate style you choose.
