ThisCalculator

Construction

Fence Spacing Calculator: Post & Rail Distance

Updated · Standard formula, shown below

The calculator for this page is switched off while it is checked. The formula is below, and the worked example in the article shows how to use it by hand.

Fence Spacing Calculator: Post & Rail Distance

A fence spacing calculator works out the maximum distance between fence posts (or between rails and pickets) for a given span, board width, and gap, or conversely how many posts you need for a total run. You enter the total fence length, the number of posts or the desired post spacing, and the calculator returns the exact on-center spacing, the number of posts required, and often the number of rails or pickets needed. This page explains the math behind those results and how to apply it to a real fence build.

Formula

The core formula for post spacing is simple: Spacing = Total Length / (Number of Posts – 1). The “–1� accounts for the fact that the first and last posts sit at the two ends, so there is one fewer gap than there are posts. For example, a 100 ft fence with 11 posts has 10 gaps, so each gap is 10 ft. The same formula works in metric: a 30 m fence with 11 posts gives 3 m spacing.

For pickets (vertical boards), the formula is slightly different. If you have a total rail length R, picket width w, and desired gap g, the number of pickets n is:

n = (R + g) / (w + g)

Then the actual gap is adjusted to fit evenly: actual gap = (R – n × w) / (n – 1). This ensures the first and last pickets are at the ends and all gaps are equal.

Worked Example

Using the calculator defaults: total length = 100 ft, number of posts = 11.

  1. Subtract 1 from the number of posts: 11 – 1 = 10 gaps.
  2. Divide total length by the number of gaps: 100 ft / 10 = 10 ft.
  3. So the on-center spacing is 10 ft, and you need 11 posts total (including both ends).

The calculator returns 10.00 ft for spacing and 11 for posts, matching the formula exactly.

When to Use a Fence Spacing Calculator

Use this calculator when you are planning a new fence, replacing posts, or building a deck railing. It helps you:

  • Determine how many posts to buy for a given run.
  • Check that your spacing meets local building codes (most codes cap post spacing at 6–8 ft for wood fences, but always verify with your local authority).
  • Plan picket layout so gaps are uniform and no picket is cut narrower than the rest.
  • Estimate materials for a quote or supply list.

For a typical residential wood privacy fence, 8 ft on-center is common, but 6 ft is safer for windy areas or heavier pickets. Metal or vinyl fences often allow 8–10 ft because the rails are stronger.

How to Read the Results

The result “spacing� is the distance from the center of one post to the center of the next. The actual opening between posts is slightly less: subtract the post width. For example, with 4×4 posts (actual 3.5 in wide) and 10 ft on-center spacing, the clear opening is 10 ft – 3.5 in = 9 ft 8.5 in.

If you are using the picket formula, the result is the number of pickets and the exact gap. Always round up the number of pickets to the next whole number, then recalculate the gap to get a uniform layout.

Common Mistakes and How to Avoid Them

  • Mixing units: Always convert inches to feet or meters before dividing. A common error is entering 100 ft and 11 posts but then reading the result as inches.
  • Forgetting the “–1â€�: Many people divide by the number of posts instead of the number of gaps. That gives a spacing that is too small and leads to buying extra posts.
  • Ignoring post width: On-center spacing is not the same as the clear opening. If you need a specific opening (e.g., for a gate), subtract the post width.
  • Rounding too early: Round only the final result. If you round the number of pickets to 20 and then compute the gap, you may get a gap that is slightly off.

Limits of the Formula

This calculator gives the geometric spacing, not the structural capacity. The actual maximum post spacing depends on the post material, diameter, depth in the ground, rail strength, and local wind/snow loads. For example, a 4×4 wood post set 2 ft deep in sandy soil may need 6 ft spacing, while a 6×6 post set 3 ft deep in clay can handle 8–10 ft. Always consult a structural engineer or your local building department for load requirements, especially for tall fences (over 6 ft) or those in high-wind zones.

The picket formula assumes the first and last pickets are at the exact ends of the rail. If you want a small overhang or a gap at the corners, adjust the formula accordingly.

Frequently Asked Questions

What is the standard fence post spacing?

For most residential wood fences, 8 feet on-center is the most common. However, many building codes require 6 feet for privacy fences or in windy regions. Always check your local code before setting posts.

How do I calculate how many posts I need for a 150-foot fence?

Divide the total length by the desired spacing, then add 1. For 8 ft spacing: 150 / 8 = 18.75, round up to 19 gaps, so you need 20 posts. If you want to use the calculator, enter 150 ft and 20 posts, and it will give you a spacing of 7.89 ft.

What is the difference between on-center and clear opening spacing?

On-center spacing is measured from the center of one post to the center of the next. Clear opening is the actual space between the inside faces of the posts. Subtract the post width (e.g., 3.5 in for a 4×4) from the on-center distance to get the clear opening.

Can I use this calculator for metal or vinyl fences?

Yes, the geometry is the same. However, metal and vinyl rails are often stronger, so you may be able to use wider spacing (8–10 ft). Always follow the manufacturer’s recommendations for the specific system you buy.

How do I space pickets evenly if my rail length isn’t a multiple of the picket width plus gap?

Use the formula: pickets = (rail length + gap) / (picket width + gap). Round down to the nearest whole number, then compute the actual gap = (rail length – pickets × picket width) / (pickets – 1). This gives you the exact uniform gap.

Does the depth of the post hole affect spacing?

Yes, deeper holes generally provide more stability, allowing wider spacing. As a rule of thumb, the hole depth should be at least 1/3 the height of the post above ground. But spacing also depends on soil type and wind load, so use engineering judgment or local codes.

Safety and Building Code Notes

Always check your local building codes before building a fence. Many jurisdictions require a permit for fences over a certain height (often 6 ft) and have specific rules for post spacing, especially near property lines or pools. For pool fences, most codes require gaps no larger than 4 inches and no horizontal rails that can be climbed. The calculator can help you plan the geometry, but it cannot replace a professional inspection or a permit.

Related

Formula used
in L | Total fence length | ft | 100 | 0
in P | Number of posts | - | 11 | 2
out spacing | Post spacing (on-center) | ft | L / (P - 1) | 2
out posts | Total posts needed | - | P | 0

Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.