Bookmarks    
nPr and nCr    
Random Number    
SD Calculator    
Sample Size    
Percent Error    
Density    
Molarity    
Molar Mass    
Ohm's Law    
Watts to Amps    
Voltage Drop    
Long Division    
Mixed Numbers    
Rounding    
Nth Root    
Exponents    
Half-Life    
Polar Form    
De Moivre    
3D Distance    
Point to Line    
Cross Product    
Determinant    
Sin Cos Tan    
Triangle Area    
Scale Factor    
Sector Area    
Ellipse Area    
Cube Volume    
Box Volume    
Sphere Volume    
Cone Volume    
Pipe Volume    
Time Duration    
Time Card    
Present Value    
Future Value    
Churn Rate    
A/B Test Calc    
SEO Traffic    
Ideal Weight    
Fat Intake    
Child Height    
Golf Handicap    
Heat Index    
Wind Chill    
Dew Point    
Download Time    
kWh to Cost    
AC Size (BTU)    
Heating Costs    
LED Savings    
Trip Gas Cost    
Tire Size    
Solar Output    
Solar Payback    
Battery Size    
Wall Area    
Gravel Needed    
Mortar Mix    
Slope Grade    
Curtain Size    
Soil Needed    
Sod Needed    
Ramp Length    
Blind Size    
Drain Slope    
Board Feet    
Heat Loss    
Furniture Fit    
Moving Boxes    
Plywood Cuts    
Shelf Sag    
   Add
Probability and random number calculators
Independent Events
Independent Events
Two Events Solver
Two Events Solver
Repeated Trials
Repeated Trials
Bayes' Theorem
Bayes' Theorem
Expected Value
Expected Value
Binomial Distribution
Binomial Distribution
nPr and nCr
nPr and nCr
Circular Permutation
Circular Permutation
With Repetition
With Repetition
Random Number
Random Number
Averages and statistics calculators
Average Calculator
Average Calculator
Mean Median Mode
Mean Median Mode
SD Calculator
SD Calculator
Quartiles & IQR
Quartiles & IQR
Frequency Table
Frequency Table
Correlation (r)
Correlation (r)
Normal Probability
Normal Probability
Z-Score Calculator
Z-Score Calculator
Confidence Interval
Confidence Interval
Sample Size
Sample Size
Mark & Recapture
Mark & Recapture
P-Value Calculator
P-Value Calculator
Percentage and ratio calculators
Percentage Calc
Percentage Calc
Percent Change
Percent Change
Percent Difference
Percent Difference
Percent Error
Percent Error
Ratio Calculator
Ratio Calculator
Discount Calculator
Discount Calculator
Sales Tax Calculator
Sales Tax Calculator
Margin Calculator
Margin Calculator
Speed calculators
Speed Calculator
Speed Calculator
Density and concentration calculators
Density
Density
Molarity
Molarity
Molar Mass
Molar Mass
Physics and electricity calculators
Ohm's Law
Ohm's Law
Watts to Amps
Watts to Amps
Resistor Colors
Resistor Colors
Voltage Drop
Voltage Drop
Unit conversion calculators
Weight Converter
Weight Converter
Shoe Size Converter
Shoe Size Converter
Integer and signed number calculators
Long Division
Long Division
LCM Calculator
LCM Calculator
GCF Calculator
GCF Calculator
Integer Calculator
Integer Calculator
Prime Factorization
Prime Factorization
Diophantine Solver
Diophantine Solver
Modulo Calculator
Modulo Calculator
Factor Calculator
Factor Calculator
Roman Numerals
Roman Numerals
Fraction, decimal and rounding calculators
Fraction Calculator
Fraction Calculator
Mixed Numbers
Mixed Numbers
Simplify Fractions
Simplify Fractions
Fraction to Decimal
Fraction to Decimal
Decimal to Fraction
Decimal to Fraction
Rounding
Rounding
Equation and inequality calculators
Linear Equation
Linear Equation
Linear Systems
Linear Systems
Quadratic Formula
Quadratic Formula
Absolute Value
Absolute Value
Quadratic Inequality
Quadratic Inequality
Polynomial calculators
Binomial Theorem
Binomial Theorem
Square root and nth root calculators
Simplify Radicals
Simplify Radicals
Nth Root
Nth Root
Exponent and logarithm calculators
Exponents
Exponents
Log Calculator
Log Calculator
Number of Digits
Number of Digits
Scientific Notation
Scientific Notation
Sci. Notation Math
Sci. Notation Math
Half-Life
Half-Life
Complex number calculators
Complex Numbers
Complex Numbers
Polar Form
Polar Form
De Moivre
De Moivre
Function and graph calculators
Slope Calculator
Slope Calculator
Linear Function
Linear Function
Direct & Inverse Variation
Direct & Inverse Variation
y = ax² Calculator
y = ax² Calculator
Distance Formula
Distance Formula
3D Distance
3D Distance
Section Formula
Section Formula
Point to Line
Point to Line
Lat/Long Distance
Lat/Long Distance
Complete the Square
Complete the Square
Circle Equation
Circle Equation
Conic Sections
Conic Sections
Polar Coordinates
Polar Coordinates
Sequence calculators
Arithmetic Sequence
Arithmetic Sequence
Geometric Sequence
Geometric Sequence
Fibonacci Sequence
Fibonacci Sequence
Recurrence Relation
Recurrence Relation
Vector calculators
Vector Calculator
Vector Calculator
Cross Product
Cross Product
Matrix calculators
Matrix Calculator
Matrix Calculator
Determinant
Determinant
Inverse Matrix
Inverse Matrix
Plane geometry calculators
Sin Cos Tan
Sin Cos Tan
Degrees ⇔ Radians
Degrees ⇔ Radians
a sin θ + b cos θ
a sin θ + b cos θ
Triangle Solver
Triangle Solver
Triangle Area
Triangle Area
Right Triangle
Right Triangle
Pythagorean Theorem
Pythagorean Theorem
Polygon Angles
Polygon Angles
Scale Factor
Scale Factor
Parallel Lines
Parallel Lines
Rectangle Area
Rectangle Area
Parallelogram Area
Parallelogram Area
Trapezoid Area
Trapezoid Area
Circle Calculator
Circle Calculator
Sector Area
Sector Area
Inscribed Angle
Inscribed Angle
Ellipse Area
Ellipse Area
Solid geometry calculators
Cube Volume
Cube Volume
Cube Surface Area
Cube Surface Area
Box Volume
Box Volume
Box Surface Area
Box Surface Area
Cylinder Volume
Cylinder Volume
Cylinder Surface
Cylinder Surface
Sphere Volume
Sphere Volume
Sphere Surface
Sphere Surface
Spherical Cap Volume
Spherical Cap Volume
Cap Surface Area
Cap Surface Area
Ellipsoid Volume
Ellipsoid Volume
Ellipsoid Surface
Ellipsoid Surface
Pyramid Volume
Pyramid Volume
Pyramid Surface
Pyramid Surface
Cone Volume
Cone Volume
Cone Surface Area
Cone Surface Area
Frustum Volume
Frustum Volume
Frustum Surface Area
Frustum Surface Area
Pipe Volume
Pipe Volume
Capsule Volume
Capsule Volume
Capsule Surface Area
Capsule Surface Area
Date and time calculators
Age Calculator
Age Calculator
Days Between Dates
Days Between Dates
Date Calculator
Date Calculator
Hours From Now
Hours From Now
Day of the Week
Day of the Week
Time Calculator
Time Calculator
Time Zone Converter
Time Zone Converter
Hours Calculator
Hours Calculator
Time Duration
Time Duration
Time Card
Time Card
Finance and economics calculators
Compound Interest
Compound Interest
Simple Interest
Simple Interest
Interest Calculator
Interest Calculator
TVM Calculator
TVM Calculator
Present Value
Present Value
Future Value
Future Value
ROI Calculator
ROI Calculator
IRR Calculator
IRR Calculator
Payback Period
Payback Period
Average Return
Average Return
GDP Calculator
GDP Calculator
Web marketing and ad metric calculators
CTR Calculator
CTR Calculator
Conversion Rate
Conversion Rate
CPC, CPM & CPA
CPC, CPM & CPA
ROAS Calculator
ROAS Calculator
Break-Even CPA
Break-Even CPA
LTV Calculator
LTV Calculator
CAC Calculator
CAC Calculator
Churn Rate
Churn Rate
A/B Test Calc
A/B Test Calc
A/B Sample Size
A/B Sample Size
SEO Traffic
SEO Traffic
Break-Even Point
Break-Even Point
Markup vs. Margin
Markup vs. Margin
CAGR Calculator
CAGR Calculator
Health and fitness calculators
BMI Calculator
BMI Calculator
Sleep Calculator
Sleep Calculator
Calorie Calculator
Calorie Calculator
BMR Calculator
BMR Calculator
TDEE Calculator
TDEE Calculator
Ideal Weight
Ideal Weight
Body Fat Calculator
Body Fat Calculator
Lean Body Mass
Lean Body Mass
Calories Burned
Calories Burned
Protein Intake
Protein Intake
Macro Calculator
Macro Calculator
Carb Calculator
Carb Calculator
Fat Intake
Fat Intake
Child Height
Child Height
Sports calculators
Golf Handicap
Golf Handicap
Pace Calculator
Pace Calculator
1RM Calculator
1RM Calculator
Target Heart Rate
Target Heart Rate
Weather calculators
Heat Index
Heat Index
Wind Chill
Wind Chill
Dew Point
Dew Point
Computer calculators
Base Converter
Base Converter
Subnet Calculator
Subnet Calculator
Download Time
Download Time
Household energy and budget calculators
Electricity Cost
Electricity Cost
kWh to Cost
kWh to Cost
Yearly kWh to Cost
Yearly kWh to Cost
AC Size (BTU)
AC Size (BTU)
AC Running Cost
AC Running Cost
Heating Costs
Heating Costs
Gas vs Electric
Gas vs Electric
LED Savings
LED Savings
Salary Calculator
Salary Calculator
Budget Calculator
Budget Calculator
Car calculators
Trip Gas Cost
Trip Gas Cost
EV Charging Cost
EV Charging Cost
EV vs Gas Cost
EV vs Gas Cost
MPG Calculator
MPG Calculator
Tire Size
Tire Size
Solar power and battery calculators
Solar Output
Solar Output
Solar Panel Count
Solar Panel Count
Solar Payback
Solar Payback
Battery Size
Battery Size
Home and DIY calculators
Tile Calculator
Tile Calculator
Stair Calculator
Stair Calculator
Concrete Volume
Concrete Volume
Wall Area
Wall Area
Wallpaper Rolls
Wallpaper Rolls
Paint Calculator
Paint Calculator
Flooring Needed
Flooring Needed
Exterior Walls
Exterior Walls
Gravel Needed
Gravel Needed
Mortar Mix
Mortar Mix
Slope Grade
Slope Grade
Lumber Cut List
Lumber Cut List
Lot Coverage/FAR
Lot Coverage/FAR
Sheet Vinyl Roll
Sheet Vinyl Roll
Insulation Needed
Insulation Needed
Curtain Size
Curtain Size
TV Size & Distance
TV Size & Distance
Soil Needed
Soil Needed
Sod Needed
Sod Needed
Block Calculator
Block Calculator
Brick Calculator
Brick Calculator
Deck Materials
Deck Materials
Ramp Length
Ramp Length
Pilot Hole Size
Pilot Hole Size
Room Ventilation
Room Ventilation
Paint Thinning
Paint Thinning
Baseboard & Trim
Baseboard & Trim
Blind Size
Blind Size
Picture Hanging
Picture Hanging
Drain Slope
Drain Slope
Screw Calculator
Screw Calculator
Board Feet
Board Feet
Fence Calculator
Fence Calculator
Wood Shrinkage
Wood Shrinkage
Caulk Calculator
Caulk Calculator
Heat Loss
Heat Loss
Furniture Fit
Furniture Fit
Moving Boxes
Moving Boxes
Storage Capacity
Storage Capacity
Plywood Cuts
Plywood Cuts
Shelf Sag
Shelf Sag

Fence Calculator (Posts, Panels, Rails and Pickets)

Choose what to find, then enter the side lengths (m) and the panel width for a panel fence, or the height, post spacing, rows of rails and board size for a wood fence. Stock lengths, mortar per hole and prices can be left blank.

Enter side lengths in meters, and the panel width, spacing, board sizes and height in millimeters. The sides are counted as one connected fence that turns a corner after each side, starting from side 1 (corners = sides − 1). Blank fields use a 10 mm gap, 2 rows of rails and a 5% waste factor.
Result and figure
Enter the length of each side and the panel width (or the post spacing and board size) on the left and press "Calculate". The counts and a drawing of the fence will appear here.

What you can do on this page

  • Enter the length of each side (one side for a straight fence, up to 4 sides if it turns corners) and the panel width (post spacing). You get the panels and posts for a vinyl, aluminum or chain link fence, and how wide to cut the last panel
  • Choose one shared corner post, or a separate post for each side (2 posts at each corner). There is one footing per post, and if you set the posts in concrete, the total concrete is found from the amount per hole
  • For a DIY wood fence, it finds the posts and the actual spacing from the maximum post spacing (such as 8 ft), the rails from the number of rows, and the pickets (vertical boards) or horizontal boards from the board width and gap, with a waste factor
  • Work backward from the panels you have to the length they cover and the posts needed. Enter prices (optional) for panels, boards, rails, posts and footings to get the cost of each material and the total
  • A drawing of each side (posts, panels or boards, rails and footings) lets you check the layout as you count. A plain-language explanation of the formulas and copy-and-paste formulas for Excel, Google Sheets and Python are also on this page
This page counts pieces from the layout. Anything that affects safety, such as post size, burial depth, footing size, wind load and bracing, should follow the fence maker's installation instructions or your supplier. Before you build, check where your property line is, the height limits of your city and HOA, and call 811 to have buried utility lines marked before you dig. For a block wall under the fence, use the "Block Wall Calculator". To cut fence boards from stock lengths, use the "Lumber Cut List Calculator".

What is this calculation used for?

Putting up a vinyl privacy fence along the property line

For 50 ft along the property line and 30 ft after the corner, 8 ft vinyl panels take \(\lceil 600 \div 96 \rceil = 7\) and \(\lceil 360 \div 96 \rceil = 4\), 11 panels in all. With one shared corner post there are \(11 + 1 = 12\) posts, and at 1.2 ft³ of concrete per hole that is 14.4 ft³, or 24 bags of 80 lb concrete mix.
When you order materials yourself, you need counts like "so many panels, posts, post caps and bags of concrete", and knowing how wide to cut the last panel makes the job go smoothly. Before you dig, check the property line and the height limits of your city and HOA, and call 811 to have buried utility lines marked.

Buying materials for a DIY wood privacy fence

For a wood privacy fence 6 ft tall and 50 ft long, posts no more than 8 ft apart give \(\lceil 600 \div 96 \rceil + 1 = 8\) posts, and 3 rows of rails give \(3 \times 7 = 21\) rails. 1×6 pickets (5.5 in) with a 1/4 in gap come to \(\lceil 600 \div 5.75 \rceil = 105\) pickets, or 111 with a 5% waste factor.
6 ft pickets fit a 6 ft fence exactly, while 8 ft boards would leave a 2 ft offcut from each one, so the stock length you choose changes the waste a lot. A privacy fence catches the wind, so follow your supplier's advice on post size, burial depth and bracing, and use this page for the counts.

Reading a fence contractor's quote

A quote lists quantities such as "panels", "line posts", "corner posts", "end posts", "gate" and "bags of concrete". Knowing these formulas lets you follow how each quantity comes from the size of your yard, and makes it easier to sort out what to ask (how the corners are built, how the ends are cut, where the gate goes, and whether the fence sits on an existing wall).
A real quote also includes removing the old fence, hauling away dirt, labor and overhead, so the material counts alone cannot tell you whether the price is fair.

Garden fences, dog runs and enclosures

A chain link or welded wire fence around a garden or dog run is counted the same way: side length ÷ post spacing, rounded up, gives the spans, and spans + 1 gives the posts on each side. For example, a 30 ft side with posts no more than 10 ft (120 in) apart has \(\lceil 360 \div 120 \rceil = 3\) spans and 4 posts. Even a fence that goes all the way around stops at the gate, so enter the sides in order starting from one side of the gate, and leave the gate width out of the side lengths (if the gate is in the middle of a side, split that side in two at the gate). Shared or double corner posts change the count by the number of corners.
If you set the posts in concrete, the total from the amount per hole tells you how many bags to buy, and the "Mortar and Concrete Mix Calculator" finds the cement and sand if you mix your own.

Checking how far leftover panels or a kit will reach

With a kit of "4 panels and 5 posts", or panels left over from an earlier job, panels × panel width gives \(4 \times 96 = 384\) in, so they cover 32 ft, and the posts are panels + 1 = 5. This tells you how much more you need to buy.

Formulas and figures

Panels (panel fence)
Figure
Standard notation (the usual math form)
\(n_{i}\) \(=\) \(\lceil\) \(L_{i}\) \(\div\) \(w\) \(\rceil\)
\(N\) \(=\) \(n_{1} + n_{2} + \cdots + n_{k}\)
In words (symbols replaced with words)
③ \(n_{i}\): panels on side \(i\) \(=\) \(\lceil\) ① \(L_{i}\): side length \(\div\) ② \(w\): panel width (post spacing) \(\rceil\)
④ \(N\): total panels \(=\) panels on each side \(n_{1} + n_{2} + \cdots + n_{k}\)
The formula in words
① Divide the \(L_{i}\): side length by the
② \(w\): panel width (post spacing) to see how many panels fit, and round up (the symbol \(\lceil\ \rceil\) stands for "round up") to get the
③ \(n_{i}\): panels on side \(i\) . With 2 or more sides, add the panels of every side to get the
④ \(N\): total panels
Quick example
For an L-shaped fence with side 1 of 50 ft (600 in) and side 2 of 30 ft (360 in), using 8 ft panels (posts 96 in on center), the panels are
side 1 panels \(n_{1}\) \(=\) \(\lceil\) side 1 (600 in) \(\div\) panel width (96 in) \(\rceil\)
\(\lceil 600 \div 96 \rceil = \lceil 6.25 \rceil = 7\)
\(\lceil 360 \div 96 \rceil = \lceil 3.75 \rceil = 4\)
\(N = 7 + 4 = 11\)
Key idea
Panel fences come with a set post spacing, such as one 8 ft panel between posts 96 in on center. The panel itself is a little shorter than the spacing, but you count the layout with the post spacing \(w\). When a side does not divide evenly by the panel width, the last panel is cut to fit. In the example, the last panel on side 1 is \(600 - 96 \times 6 = 24\) in and on side 2 it is \(360 - 96 \times 3 = 72\) in. Vinyl and aluminum panels are usually cut on site and finished with trim, and chain link is cut and tied off at the end post. Check the installation instructions for how and how much you can cut. Panels cannot continue around a corner, so the panels are rounded up side by side. Dividing the total 80 ft by 8 ft gives 10, but the fence really needs 11 panels.
Posts (panel fence)
Figure
Standard notation (the usual math form)
\(P\) \(=\) \(N\) \(+\) \(k\)
\(P\) \(=\) \(N\) \(+\) \(1\)
In words (symbols replaced with words)
③ \(P\): posts \(=\) ① \(N\): total panels \(+\) ② \(k\): number of sides (2 posts at each corner)
\(P\): posts \(=\) \(N\): total panels \(+\) ④ 1 for the end (shared corner posts)
The formula in words
① Add the \(N\): total panels and the
② \(k\): number of sides to get the
③ \(P\): posts (each side takes panels + 1 posts, so 1 is added once per side). With shared corner posts, you only add the
④ 1 for the end
Quick example
For the example above (7 panels on side 1 and 4 on side 2, 11 in all), the posts with 2 posts at the corner and with one shared corner post are
posts \(P\) \(=\) panels (11) \(+\) sides (2)
\(P = (7 + 1) + (4 + 1) = 11 + 2 = 13\)
\(P = 11 + 1 = 12\)
Key idea
On a straight fence there is a post on both sides of every panel, so there is one more post than panels (the fencepost problem: posts along a road number spaces + 1 when both ends get a post). When the fence turns corners and each side is counted this way, the total is the total panels plus the number of sides. How corners are built depends on the product. Most US wood, vinyl and chain link fences use a single corner post that takes the panels or rails from both sides, so each corner saves one post and \(P = N + 1\). Some panel systems end each side with its own post and join the two with a corner connector. Then there are 2 posts at each corner, and you need as many connectors as corners (sides − 1). This calculator counts the sides as one fence that runs from side 1 and turns a corner after each side (corners = sides − 1). To count separate fences in different places together, choose "A post at each end of every side", which gives panels + 1 for each side. A closed loop with corner posts and no opening would need \(P = N\), because there are no ends. End caps, gate posts and braces for tall fences are not included in this count. Count gate posts separately to suit the gate.
Footings and post hole concrete
Standard notation (the usual math form)
\(F\) \(=\) \(P\)
\(V\) \(=\) \(P\) \(\times\) \(v\)
In words (symbols replaced with words)
② \(F\): footings \(=\) ① \(P\): posts
④ \(V\): total post hole concrete \(=\) \(P\): posts \(\times\) ③ \(v\): concrete per hole
The formula in words
① You need as many \(P\): posts as
② \(F\): footings . If you set the posts in concrete, multiply the posts by the
③ \(v\): concrete per hole to get the
④ \(V\): total post hole concrete
Quick example
For 12 posts, each set in 1.2 ft³ of concrete, the footings and the concrete are
concrete \(V\) \(=\) posts (12) \(\times\) per hole (1.2 ft³)
\(F = 12\)
\(12 \times 1.2 = 14.4\,\mathrm{ft^3}\)
Key idea
Each post is anchored in the ground on its own, so there is one footing per post. In the US, posts are usually set in holes filled with bagged concrete mix, so the posts equal the post holes. With precast post bases, the posts equal the bases. The concrete for one hole is the volume of the hole minus the part taken by the post. For a 10 in diameter hole 30 in deep, the hole holds \(3.14 \times 5 \times 5 \times 30 \approx 2356\) in³. A 4×4 post (3.5 in square) takes \(3.5 \times 3.5 \times 30 = 367.5\) in³ of it, which leaves about 1,989 in³, or \(1989 \div 1728 \approx 1.15\) ft³. Holes are rarely perfectly neat, so allow a little extra. An 80 lb bag of concrete mix makes about 0.6 ft³, so 14.4 ft³ is \(14.4 \div 0.6 = 24\) bags. The "Mortar and Concrete Mix Calculator" finds the cement, sand, gravel and water for mixing your own. Hole size and depth depend on the fence height, weight and wind, and on the frost depth where you live. A common rule of thumb is a hole about three times the post width, with about a third of the post in the ground, but follow the manufacturer's instructions and local code. This page only counts the footings and the amount.
Posts and actual spacing (wood or DIY fence)
Figure
Standard notation (the usual math form)
\(P_{i}\) \(=\) \(\lceil\) \(L_{i}\) \(\div\) \(p\) \(\rceil\) \(+\) \(1\)
\(p'_{i}\) \(=\) \(L_{i}\) \(\div\) \((\) \(P_{i}\) \(-\) \(1\) \()\)
In words (symbols replaced with words)
④ \(P_{i}\): posts on side \(i\) \(=\) \(\lceil\) ① \(L_{i}\): side length \(\div\) ② \(p\): post spacing \(\rceil\) \(+\) ③ 1 for the end
⑤ \(p'_{i}\): actual spacing \(=\) \(L_{i}\): side length \(\div\) \((\) \(P_{i}\): posts on side \(i\) \(-\) \(1\) \()\)
The formula in words
① Divide the \(L_{i}\): side length by the
② \(p\): post spacing and round up to get the number of spans. Add
③ 1 for the end to get the
④ \(P_{i}\): posts on side \(i\) . Dividing the side length by the spans (posts − 1) gives the
⑤ \(p'_{i}\): actual spacing
Quick example
For a straight fence 50 ft (600 in) long with posts no more than 8 ft (96 in) apart, the posts and the actual spacing are
posts \(P_{1}\) \(=\) \(\lceil\) side length (600 in) \(\div\) spacing (96 in) \(\rceil\) \(+\) 1 for the end
\(\lceil 600 \div 96 \rceil + 1 = 7 + 1 = 8\)
\(p'_{1} = 600 \div (8 - 1) \approx 85.7\)
Key idea
On a wood fence you choose the post spacing yourself. There is always a post at both ends of a side, so the posts are spans + 1 (the fencepost rule). The spans are rounded up so the spacing is no more than the value you chose. 50 ft with posts no more than 8 ft apart gives 7 spans and 8 posts, and the actual spacing is \(600 \div 7 \approx 85.7\) in (with 7 posts, the spacing would be 100 in, wider than you wanted). 6 to 8 ft is the common range, decided by the weight of the boards and how much wind the fence catches. For a privacy fence 6 ft tall or more that takes the full force of the wind, consider closer posts, larger posts or bracing, together with the post size, burial depth and footing size recommended by your supplier. With 2 or more sides, add the posts of each side. With shared corner posts, subtract the corners (sides − 1).
Rails and total rail length
Standard notation (the usual math form)
\(R\) \(=\) \(t\) \(\times\) \(q\)
\(\ell_{R}\) \(=\) \(t\) \(\times\) \(L\)
In words (symbols replaced with words)
③ \(R\): rails \(=\) ① \(t\): rows of rails \(\times\) ② \(q\): total spans
⑤ \(\ell_{R}\): total rail length \(=\) \(t\): rows of rails \(\times\) ④ \(L\): total fence length
The formula in words
① Multiply the \(t\): rows of rails by the
② \(q\): total spans (posts − 1 for each side, added up) to get the
③ \(R\): rails . Multiply the rows by the
④ \(L\): total fence length to get the
⑤ \(\ell_{R}\): total rail length
Quick example
For a 50 ft fence with 8 posts (7 spans) and 3 rows of rails, the rails and the total rail length are
rails \(R\) \(=\) rows (3) \(\times\) spans (7)
\(3 \times 7 = 21\)
\(\ell_{R} = 3 \times 50 = 150\,\mathrm{ft}\)
Key idea
Rails are the horizontal boards between the posts that the fence boards are fastened to. They are joined at the posts, so there is one rail per span in each row. Fences about 4 ft tall usually have 2 rows, and 6 ft privacy fences usually have 3 (top, middle and bottom), depending on the board thickness and the wind. Each rail is as long as the actual post spacing (85.7 in in the example). If you enter the rail stock length, the page also finds the stock lengths needed, from how many spans one stock length gives. An 8 ft (96 in) 2×4 gives \(\lfloor 96 \div 85.7 \rfloor = 1\) span, so you need 21 of them. For a fence with rails that run past the posts over several spans, total length ÷ stock length is a closer count than one rail per span.
Boards (vertical pickets and horizontal boards)
Figure
Standard notation (the usual math form)
\(n_{i}\) \(=\) \(\lceil\) \(L_{i}\) \(\div\) \((\) \(b\) \(+\) \(s\) \()\) \(\rceil\)
\(m\) \(=\) \(\lceil\) \(H\) \(\div\) \((\) \(b\) \(+\) \(s\) \()\) \(\rceil\)
\(B_{i}\) \(=\) \(m\) \(\times\) \(\lceil\) \(L_{i}\) \(\div\) \(\ell\) \(\rceil\)
In words (symbols replaced with words)
④ \(n_{i}\): vertical boards on side \(i\) \(=\) \(\lceil\) ① \(L_{i}\): side length \(\div\) \((\) ② \(b\): board width \(+\) ③ \(s\): gap \()\) \(\rceil\)
⑥ \(m\): rows of horizontal boards \(=\) \(\lceil\) ⑤ \(H\): fence height \(\div\) \((\) \(b\): board width \(+\) \(s\): gap \()\) \(\rceil\)
⑧ \(B_{i}\): horizontal boards on side \(i\) \(=\) \(m\): rows of horizontal boards \(\times\) \(\lceil\) \(L_{i}\): side length \(\div\) ⑦ \(\ell\): board stock length \(\rceil\)
The formula in words
① Divide the \(L_{i}\): side length by the width per board, the
② \(b\): board width plus the
③ \(s\): gap , and round up to get the
④ \(n_{i}\): vertical boards on side \(i\) . For horizontal boards, divide the
⑤ \(H\): fence height by the same width per board and round up to get the
⑥ \(m\): rows of horizontal boards . Multiply it by the boards per row (the side length divided by the
⑦ \(\ell\): board stock length , rounded up) to get the
⑧ \(B_{i}\): horizontal boards on side \(i\)
Quick example
For a 50 ft (600 in) fence 6 ft tall with 1×6 pickets (5.5 in wide) and a 1/4 in gap, the pickets are as follows. The rows and boards are also shown for a 16 ft (192 in) fence 72 in tall with horizontal 1×6s (5.5 in wide), a 1/2 in gap and 8 ft (96 in) boards
pickets \(n_{1}\) \(=\) \(\lceil\) side 1 (600 in) \(\div\) \((\) width (5.5 in) \(+\) gap (0.25 in) \()\) \(\rceil\)
\(\lceil 600 \div (5.5 + 0.25) \rceil = \lceil 104.35 \rceil = 105\)
\(m = \lceil 72 \div (5.5 + 0.5) \rceil = \lceil 12 \rceil = 12\)
\(B_{1} = 12 \times \lceil 192 \div 96 \rceil = 12 \times 2 = 24\)
Key idea
For vertical boards (pickets), divide the side length by "board width + gap" per board, just like deck boards. The last board is ripped to fit, or the gaps are adjusted slightly. Each board is as long as the height you entered (the height covered by boards, minus any gap above the ground). If you enter the board stock length, the page also finds the stock lengths needed from how many boards one stock length gives (a 96 in board gives two 48 in boards). For horizontal boards, divide the height by "board width + gap" to get the rows, and multiply by the stock lengths in each row. Board joints must land on a post, so in practice the boards are cut at the posts, which leaves offcuts. The "Lumber Cut List Calculator" finds the least wasteful way to cut them with the joints included. The 1/4 in default gap is for privacy. For more air and light, 1 to 2 in is common, and the wider the gap, the fewer boards you need. Many privacy fences butt the boards tight (gap 0), because the boards shrink as they dry.
Boards to buy with waste
Standard notation (the usual math form)
\(B'\) \(=\) \(\lceil\) \(B\) \(\times\) \(\left(1 + \dfrac{r}{100}\right)\) \(\rceil\)
In words (symbols replaced with words)
③ \(B'\): boards to buy with waste \(=\) \(\lceil\) ① \(B\): boards (net) \(\times\) ② waste multiplier for \(r\)% \(\left(1 + \dfrac{r}{100}\right)\) \(\rceil\)
The formula in words
① Multiply the \(B\): boards (net) by the
② waste multiplier \(\left(1 + \dfrac{r}{100}\right)\) for the waste factor \(r\) and round up to get the
③ \(B'\): boards to buy with waste
Quick example
For 105 pickets (net) with a 5% waste factor, the boards to buy are
to buy \(B'\) \(=\) \(\lceil\) net (105) \(\times\) multiplier (1.05) \(\rceil\)
\(\lceil 105 \times 1.05 \rceil = \lceil 110.25 \rceil = 111\)
Key idea
The waste factor is the extra you buy on top of the net amount. For wood fence boards, the waste comes from ripping the last board, cutting off split ends, skipping boards with bad knots, and spares for mistakes. 5 to 10% is typical, more if you cut many pieces from stock lengths. This calculator applies the waste factor to the boards only. Posts and rails are few and counted one by one, so no waste factor is added to them. Panels get no waste factor either. They are bought one at a time and the last one is cut to fit, so in practice you check the cut width instead of buying extra.
Working backward: length the panels you have will cover
Standard notation (the usual math form)
\(L_{\max}\) \(=\) \(N\) \(\times\) \(w\)
\(P\) \(=\) \(N\) \(+\) \(1\)
In words (symbols replaced with words)
③ \(L_{\max}\): length you can fence \(=\) ① \(N\): panels on hand \(\times\) ② \(w\): panel width (post spacing)
⑤ \(P\): posts \(=\) \(N\): panels on hand \(+\) ④ 1 for the end
The formula in words
① Multiply the \(N\): panels on hand by the
② \(w\): panel width (post spacing) to get the
③ \(L_{\max}\): length you can fence . Adding
④ 1 for the end to the panels gives the
⑤ \(P\): posts for a straight fence
Quick example
With 4 panels for posts 96 in (8 ft) on center, the length you can fence in a straight line and the posts are
length you can fence \(L_{\max}\) \(=\) panels (4) \(\times\) panel width (96 in)
\(4 \times 96 = 384\,\mathrm{in} = 32\,\mathrm{ft}\)
\(P = 4 + 1 = 5\)
Key idea
This formula checks how far leftover panels, or a kit of "so many panels and posts", will reach. Panels × panel width is the length you can fence, and as usual there is one more post than panels. If the fence will turn a corner, split the panels by side and count again with the "Panels" and "Posts" formulas.
Estimated cost
Standard notation (the usual math form)
\(C\) \(=\) \(u\) \(\times\) \(Q\)
\(T\) \(=\) \(C_{1}\) \(+\) \(C_{2}\) \(+\) \(C_{3}\) \(+\) \(C_{4}\)
In words (symbols replaced with words)
③ \(C\): cost of each material \(=\) ① \(u\): unit price \(\times\) ② \(Q\): quantity
④ \(T\): total estimated cost \(=\) \(C_{1}\): panels or boards \(+\) \(C_{2}\): rails \(+\) \(C_{3}\): posts \(+\) \(C_{4}\): footings
The formula in words
① Multiply the \(u\): unit price (per panel or board, per rail or post, per footing) by the
② \(Q\): quantity (panels, boards, rails, posts or footings to match the price) to get the
③ \(C\): cost of each material . Add the panels (or boards), rails, posts and footings together to get the
④ \(T\): total estimated cost
Quick example
For 11 vinyl panels at $85 each, 12 posts at $45 each and concrete for 12 post holes at $12 each (two 80 lb bags), the cost is
\(85 \times 11 = 935\)
\(45 \times 12 = 540\)
\(12 \times 12 = 144\)
\(935 + 540 + 144 = 1619\)
Key idea
The key is to match the units of the price and the quantity. Multiply panels by the panels \(N\), boards by the boards to buy with waste \(B'\), rails by the stock lengths (or by the rails per span \(R\) if you did not enter a stock length), and posts and footings by the posts \(P\). This covers only the panels, boards, rails, posts and footings. Corner connectors, end caps, gates, braces, screws and brackets, stain, tool rental, and labor and dirt removal if you hire a contractor are extra. Use the "Paint Calculator" for stain and the "Mortar and Concrete Mix Calculator" for concrete materials.
Panels are the side length ÷ panel width, rounded up side by side. Posts follow the fencepost rule, panels + 1 (or side length ÷ spacing, rounded up, + 1 for a wood fence), and shared or double corner posts change the count by the number of corners (sides − 1). There is one footing per post, and the boards get a waste factor (about 5 to 10%). Check post size, footing size, property lines and height limits against the maker's instructions, local code and your HOA, and call 811 before you dig.

Symbols and terms

Symbols

\(L_{i}\) L sub i The length of side \(i\) (the 1st, 2nd and so on). From "length". It is entered in feet and changed to inches for the calculation.
\(k\) k The number of sides (1 to 4). 1 for a straight fence, 2 for an L shape and 3 for a U shape. The corners number \(k - 1\).
\(L\) L The total fence length, all the sides added together: \(L = L_{1} + L_{2} + \cdots + L_{k}\).
\(w\) w The panel width (= post spacing on center, in inches). From "width". For example, 96 in for an 8 ft vinyl panel.
\(n_{i}\) n sub i The panels on side \(i\) (or the vertical boards for a board fence). \(n_{i} = \lceil L_{i} \div w \rceil\). From "number".
\(N\) N The total panels, all the \(n_{i}\) added together. When working backward, it is the panels you have.
\(P\) P The posts. From "post". For a panel fence, \(P = N + k\) (2 posts at each corner) or \(N + 1\) (shared corner posts).
\(P_{i}\) P sub i The posts on side \(i\) of a wood fence. \(P_{i} = \lceil L_{i} \div p \rceil + 1\).
\(p\) lowercase p The post spacing of a wood fence (on center, in inches). From "pitch". The example uses 96 in, but it depends on the weight of the boards and the wind.
\(p'_{i}\) p prime sub i The actual post spacing on side \(i\) (in inches), after the posts are rounded up so the spacing is no more than \(p\). \(L_{i} \div (P_{i} - 1)\).
\(F\) F The footings (post holes or precast post bases). From "footing". The same as the posts: \(F = P\).
\(v\) v The concrete for one post hole (ft³). From "volume". The hole volume minus the part taken by the post.
\(V\) capital V The total post hole concrete (ft³). \(V = P \times v\).
\(t\) t The rows of rails on a wood fence. The default is 2.
\(q\) q The total spans (spaces between posts). Posts − 1 for each side, added up, which is the same as the sum of \(\lceil L_{i} \div p \rceil\).
\(R\) R The rails. From "rail". \(R = t \times q\).
\(\ell_{R}\) script l sub R The total rail length (ft). \(\ell_{R} = t \times L\). Written as a script l to tell it apart from the side length \(L\).
\(H\) H The fence height (in). From "height". Used for the length of each vertical board and for the rows of horizontal boards.
\(b\) lowercase b The width of one board (in). From "board". For example, 5.5 in for a 1×6.
\(s\) s The gap between boards (in). From "space". The default is 1/4 in.
\(m\) m The rows of horizontal boards. \(m = \lceil H \div (b + s) \rceil\).
\(\ell\) script l The stock length of the boards (in). From "length". Used for the boards in each row of horizontal boards.
\(B_{i}\) B sub i The horizontal boards on side \(i\). \(B_{i} = m \times \lceil L_{i} \div \ell \rceil\).
\(B\) B The total boards (net, without waste). The sum of \(n_{i}\) for vertical boards or of \(B_{i}\) for horizontal boards.
\(r\) lowercase r The waste factor (%). From "rate". The default is 5%.
\(B'\) B prime The boards to buy with waste. \(B' = \lceil B \times (1 + r \div 100) \rceil\).
\(L_{\max}\) L max The length the panels on hand will cover in a straight line. \(L_{\max} = N \times w\). max is short for maximum.
\(u\) u The unit price of a material ($). From "unit price". Per panel or board, per rail or post, or per footing.
\(Q\) capital Q The quantity that matches the price (panels, boards, rails, posts or footings). From "quantity".
\(C\) C The cost of each material ($). \(C = u \times Q\). From "cost".
\(T\) capital T The total estimated cost ($). From "total". Materials only (panels or boards, rails, posts and footings).
\(\lceil x \rceil\) ceiling of x The ceiling function: round up to a whole number (for example \(\lceil 6.25 \rceil = 7\) and \(\lceil 5 \rceil = 5\)).
\(\lfloor x \rfloor\) floor of x The floor function: round down to a whole number (for example \(\lfloor 1.12 \rfloor = 1\) and \(\lfloor 2.02 \rfloor = 2\)). Used for the pieces you can cut from one stock length.

Terms

post A vertical member anchored in the ground that holds up the fence. Panel fences use posts made for the system, spaced to match the panels. Wood fences usually use 4×4 or 6×6 posts, with the spacing up to you.
panel One ready-made section of fence that fits between two posts, made of vinyl, aluminum, wood or wire. Its width matches a standard post spacing, such as 6 or 8 ft.
chain link A fence of woven steel wire stretched between metal posts, common for yards, dog runs and gardens. Line posts are usually 10 ft apart or less, and the wire is sold in rolls.
privacy fence A fence with little or no gap between boards, usually 6 ft tall, so people cannot see through. It catches the full force of the wind, so it often needs closer posts or larger footings. Check the product's instructions.
rail A horizontal board, usually a 2×4, that runs between the posts of a wood fence for fastening the boards. There is one per span in each row, with 2 or 3 rows depending on the height. Also called a stringer.
stringer Another name for a fence rail. This page uses "rail".
picket A vertical fence board fastened to the rails, often a 1×6 (5-1/2 in actual width) 6 or 8 ft long. The count is side length ÷ (board width + gap), rounded up, and each is as long as the fence height.
horizontal boards A style where boards run sideways in rows. The rows are height ÷ (board width + gap) and the boards per row are side length ÷ stock length, both rounded up, with the joints on the posts.
on center The distance from the center of one member to the center of the next, written "o.c.". Post spacing is always given this way (not as the clear space between posts).
span One space between two posts, also called a bay or section. Rails are joined at the posts, so there is one rail per span in each row, and the total spans \(q\) counts these spaces on every side.
owner-supplied materials When the homeowner buys the fence materials and hires a contractor only to install them. You have to count the materials yourself, so check the panels, posts, corner parts and footings with the formulas on this page.
fencepost problem The classic math puzzle about the number of items and spaces in a row. With an item at both ends, items = spaces + 1. The "+ 1" in the post formula comes from this.
round up If there is any decimal part, go up to the next whole number. Panels, boards and posts cannot stop partway, so they are always rounded up.
round down Drop the decimal part to get a whole number. How many pieces one stock length gives is rounded down, because a partial piece is no use.
stock length The standard length that lumber is sold in. US lumber comes in 2 ft steps such as 6, 8, 10, 12 and 16 ft, and fence pickets are usually 6 or 8 ft.
cut yield How many pieces of the length you need one stock length gives. It is the stock length divided by the piece length, rounded down. The "Lumber Cut List Calculator" includes the saw kerf.
waste factor The extra you buy on top of the net amount, for offcuts from the end boards, split ends, boards with knots or warps you skip, and spares for mistakes. 5 to 10% is typical for wood fence boards.
precast post base A ready-made concrete block with a hole for a post, set in the ground instead of pouring concrete. One per post.
footing The foundation for one post. In the US it is usually concrete poured in a post hole around the post, often below the frost line in cold areas.
concrete mix Bagged cement, sand and gravel that is mixed with water. US fence posts are usually set in it (an 80 lb bag makes about 0.6 ft³). The "Mortar and Concrete Mix Calculator" finds the materials for mixing your own.
corner connector A bracket that joins two panels at a corner when each side ends in its own post. You need one per corner (sides − 1).
corner post One post at a corner that takes the panels or rails from both sides, the usual way for US wood, vinyl and chain link fences. It saves one post per corner.
end cap A cover for the end post or panel at each end of the fence. It hides the cut edge and prevents injuries. You need 2, but they are not in the counts on this page.
brace A diagonal support that keeps a tall or windy fence from leaning, common at the end and corner posts of chain link fences. Whether you need it depends on the product, so it is not counted on this page.
gate The door in a fence. Gate posts are heavier than fence posts and need larger footings, so count them separately for the gate you choose. Do not include the gate opening in the side lengths.
property line The legal boundary between your lot and your neighbor's lot or the street. Before you build, check where it is (a survey helps), how far back the fence must be, and the height limits of your city and HOA.

Good to know before you start

Here is what helps to understand before you start, so that you can use the calculations on this page with a clear understanding.

Converting units of length (Grade 4)
  • That 1 ft = 12 in, and being able to change 50 ft into 600 in
Division with remainders (Grade 3 to 4)
  • Using a division such as \(600 \div 96\) to find "how many fit" and "what is left over"
Rounding (Grade 4)
  • The difference between rounding up, rounding down and rounding to the nearest
  • Being able to explain in your own words why panels and boards are rounded up and why the pieces from one stock length are rounded down
The fencepost problem (Grade 3 to 4)
  • Being able to show with a drawing that trees planted in a row with one at each end number "spaces + 1"
  • Thinking about how the "ends" are counted at each corner of a row that turns
Percents (Grade 6)
  • That "5% more" can be calculated as "× 1.05"
Multiplying and dividing decimals (Grade 5 to 6)
  • The idea behind a calculation such as \(105 \times 1.05\) or \(600 \div 7\) (a calculator is fine for the arithmetic)

How to calculate it in Excel

Copy the whole table below and paste it into cell A1 in Excel. It works as is.
Table for the panels (panel fence)
Side 1 length L1 (in) 600
Side 2 length L2 (in, 0 if none) 360
Panel width w (in) 96
Panels on side 1 n1 =ROUNDUP(B1/B3,0)
Panels on side 2 n2 =ROUNDUP(B2/B3,0)
Total panels N =B4+B5
Table for the posts (panel fence)
Total panels N 11
Number of sides k 2
Posts P (2 per corner) =B1+B2
Posts P (shared corner) =B1+1
Table for the footings and post hole concrete
Posts P 12
Concrete per hole v (ft³) 1.2
Footings F =B1
Total concrete V (ft³) =B1*B2
Table for the posts and actual spacing (wood fence)
Side length L (in) 600
Post spacing p (in) 96
Posts P =ROUNDUP(B1/B2,0)+1
Actual spacing (in) =B1/(B3-1)
Table for the rails and total rail length
Rows of rails t 3
Total spans q 7
Total fence length L (in) 600
Rails R =B1*B2
Total rail length (ft) =B1*B3/12
Table for the pickets (vertical boards)
Side length L (in) 600
Board width b (in) 5.5
Gap s (in) 0.25
Pickets n =ROUNDUP(B1/(B2+B3),0)
Table for the horizontal boards
Fence height H (in) 72
Board width b (in) 5.5
Gap s (in) 0.5
Side length L (in) 192
Board stock length ℓ (in) 96
Rows m =ROUNDUP(B1/(B2+B3),0)
Horizontal boards B =B6*ROUNDUP(B4/B5,0)
Table for the boards to buy with waste
Boards (net) B 105
Waste factor r (%) 5
Boards to buy with waste =ROUNDUP(B1*(1+B2/100),0)
Table for working backward: length the panels you have will cover
Panels on hand N 4
Panel width w (in) 96
Length you can fence (ft) =B1*B2/12
Posts P =B1+1
Table for the estimated cost
Panel price ($ each) 85
Panels 11
Post price ($ each) 45
Posts 12
Footing price ($ each) 12
Footings 12
Total estimated cost ($) =B1*B2+B3*B4+B5*B6
After you paste, the upper rows of column B are the inputs and the last rows (and the calculation rows in between) are the calculated results.
ROUNDUP(value, 0) rounds up to a whole number (the ⌈ ⌉ in the formulas).
The 1st table gives 7, 4 and 11 panels in B4 to B6, the 2nd table gives 13 and 12 posts in B3 and B4, the 3rd table gives 12 footings and 14.4 ft³ of concrete, the 4th table gives 8 posts and about 85.7 in, the 5th table gives 21 rails and 150 ft, B4 in the 6th table is 105 pickets, the 7th table gives 12 rows and 24 boards, B3 in the 8th table is 111 boards, the 9th table gives 32 ft and 5 posts, and B7 in the 10th table is $1,619. Just replace the numbers in column B with your own. For 3 or more sides, add rows to the 1st table with the same formula.

How to calculate it in Google Sheets

Copy the whole table below and paste it into cell A1 in Google Sheets. It works as is.
Table for the panels (panel fence)
Side 1 length L1 (in) 600
Side 2 length L2 (in, 0 if none) 360
Panel width w (in) 96
Panels on side 1 n1 =ROUNDUP(B1/B3,0)
Panels on side 2 n2 =ROUNDUP(B2/B3,0)
Total panels N =B4+B5
Table for the posts (panel fence)
Total panels N 11
Number of sides k 2
Posts P (2 per corner) =B1+B2
Posts P (shared corner) =B1+1
Table for the footings and post hole concrete
Posts P 12
Concrete per hole v (ft³) 1.2
Footings F =B1
Total concrete V (ft³) =B1*B2
Table for the posts and actual spacing (wood fence)
Side length L (in) 600
Post spacing p (in) 96
Posts P =ROUNDUP(B1/B2,0)+1
Actual spacing (in) =B1/(B3-1)
Table for the rails and total rail length
Rows of rails t 3
Total spans q 7
Total fence length L (in) 600
Rails R =B1*B2
Total rail length (ft) =B1*B3/12
Table for the pickets (vertical boards)
Side length L (in) 600
Board width b (in) 5.5
Gap s (in) 0.25
Pickets n =ROUNDUP(B1/(B2+B3),0)
Table for the horizontal boards
Fence height H (in) 72
Board width b (in) 5.5
Gap s (in) 0.5
Side length L (in) 192
Board stock length ℓ (in) 96
Rows m =ROUNDUP(B1/(B2+B3),0)
Horizontal boards B =B6*ROUNDUP(B4/B5,0)
Table for the boards to buy with waste
Boards (net) B 105
Waste factor r (%) 5
Boards to buy with waste =ROUNDUP(B1*(1+B2/100),0)
Table for working backward: length the panels you have will cover
Panels on hand N 4
Panel width w (in) 96
Length you can fence (ft) =B1*B2/12
Posts P =B1+1
Table for the estimated cost
Panel price ($ each) 85
Panels 11
Post price ($ each) 45
Posts 12
Footing price ($ each) 12
Footings 12
Total estimated cost ($) =B1*B2+B3*B4+B5*B6
The same formulas as in Excel work as they are (ROUNDUP has the same name). Copy the whole table, paste it into cell A1, and replace the numbers in column B with your own.

How to calculate it in Python

import math

# ===== Panel fence =====
sides_in = [600, 360]       # side lengths (in): one for a straight fence, in order for a fence that turns corners
panel_w_in = 96             # panel width = post spacing on center (in)
is_corner_shared = True     # True for one shared corner post, False for 2 posts at each corner
hole_concrete_ft3 = 1.2     # concrete per post hole (ft3)

panels_each = [math.ceil(L / panel_w_in) for L in sides_in]              # panels per side (rounded up)
last_widths = [L - (n - 1) * panel_w_in for L, n in zip(sides_in, panels_each)]  # width of the last panel on each side
panels = sum(panels_each)
posts = panels + 1 if is_corner_shared else panels + len(sides_in)      # posts (fencepost rule)
footings = posts                                                         # footings
concrete_ft3 = posts * hole_concrete_ft3                                 # concrete (ft3)

print(f"Panels: {panels_each} per side -> {panels} total (last panel widths {last_widths} in)")
print(f"Posts: {posts}, footings: {footings}, concrete: {concrete_ft3:.1f} ft3 ({math.ceil(concrete_ft3 / 0.6)} bags of 80 lb)")

# ===== Wood or DIY fence (vertical pickets) =====
side_in = [600]             # a straight 50 ft fence
fence_h_in = 72             # fence height (in)
post_pitch_in = 96          # maximum post spacing (in)
rail_rows = 3               # rows of rails
board_w_in = 5.5            # board width (in), actual width of a 1x6
gap_in = 0.25               # gap (in)
loss_rate = 5               # waste factor (%)

spans_each = [max(math.ceil(L / post_pitch_in), 1) for L in side_in]    # spans per side
posts_wood = sum(q + 1 for q in spans_each)                              # posts
pitch_actual = [L / q for L, q in zip(side_in, spans_each)]              # actual spacing
rails = rail_rows * sum(spans_each)                                      # rails
boards = sum(math.ceil(L / (board_w_in + gap_in)) for L in side_in)      # pickets (net)
boards_buy = math.ceil(boards * (100 + loss_rate) / 100)                 # boards to buy with waste

print(f"Wood: {posts_wood} posts (actual spacing {[round(p, 1) for p in pitch_actual]} in), {rails} rails")
print(f"Pickets: {boards} net -> {boards_buy} with waste (each {fence_h_in} in long)")
It runs with the standard library only. math.ceil() rounds up (the ⌈ ⌉ in the formulas). List the side lengths in inches in sides_in, replace the panel width, spacing and board size with your own numbers, and run it. For 2 posts at each corner, set is_corner_shared to False. For horizontal boards, multiply the rows math.ceil(fence_h_in / (board_w_in + gap_in)) by math.ceil(L / stock length) for each side and add them up.

How to write it in LaTeX and other math languages (copy and paste)

Panels (panel fence)
nᵢ = ⌈Lᵢ ÷ w⌉,  N = n₁ + n₂ + … + nₖ
n_{i} = \left\lceil \frac{L_{i}}{w} \right\rceil,\quad N = \sum_{i=1}^{k} n_{i}
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
  <mrow>
    <msub><mi>n</mi><mi>i</mi></msub>
    <mo>=</mo>
    <mo>&#x2308;</mo>
    <mfrac><msub><mi>L</mi><mi>i</mi></msub><mi>w</mi></mfrac>
    <mo>&#x2309;</mo>
    <mo>,</mo>
    <mi>N</mi>
    <mo>=</mo>
    <munderover><mo>&#x2211;</mo><mrow><mi>i</mi><mo>=</mo><mn>1</mn></mrow><mi>k</mi></munderover>
    <msub><mi>n</mi><mi>i</mi></msub>
  </mrow>
</math>
n_i = |~ L_i / w ~|,  N = sum_(i=1)^k n_i
n = Ceiling[L/w]; nTotal = Total[n]
n[i] := ceil(L[i]/w);  N := add(n[i], i = 1 .. k);
n = ceil(L./w); N = sum(n);
n_i = ⌈L_i/w⌉, N = ∑_(i=1)^k n_i
Posts (panel fence)
P = N + k (2 per corner),  P = N + 1 (shared corner)
P = N + k \quad(\text{2 posts per corner}),\qquad P = N + 1 \quad(\text{shared corner})
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
  <mrow>
    <mi>P</mi>
    <mo>=</mo>
    <mi>N</mi>
    <mo>+</mo>
    <mi>k</mi>
    <mo>,</mo>
    <mi>P</mi>
    <mo>=</mo>
    <mi>N</mi>
    <mo>+</mo>
    <mn>1</mn>
  </mrow>
</math>
P = N + k,  P = N + 1
p = nTotal + k; pShared = nTotal + 1
P := N + k;  Pshared := N + 1;
P = N + k; Pshared = N + 1;
P = N + k, P = N + 1
Footings and post hole concrete
F = P,  V = P × v
F = P,\quad V = P v
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
  <mrow>
    <mi>F</mi>
    <mo>=</mo>
    <mi>P</mi>
    <mo>,</mo>
    <mi>V</mi>
    <mo>=</mo>
    <mi>P</mi>
    <mo>&#xD7;</mo>
    <mi>v</mi>
  </mrow>
</math>
F = P,  V = P * v
f = p; vTotal = p v
F := P;  V := P*v;
F = P; V = P*v;
F = P, V = P × v
Posts and actual spacing (wood or DIY fence)
Pᵢ = ⌈Lᵢ ÷ p⌉ + 1,  p'ᵢ = Lᵢ ÷ (Pᵢ − 1)
P_{i} = \left\lceil \frac{L_{i}}{p} \right\rceil + 1,\quad p'_{i} = \frac{L_{i}}{P_{i} - 1}
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
  <mrow>
    <msub><mi>P</mi><mi>i</mi></msub>
    <mo>=</mo>
    <mo>&#x2308;</mo>
    <mfrac><msub><mi>L</mi><mi>i</mi></msub><mi>p</mi></mfrac>
    <mo>&#x2309;</mo>
    <mo>+</mo>
    <mn>1</mn>
    <mo>,</mo>
    <msubsup><mi>p</mi><mi>i</mi><mo>&#x2032;</mo></msubsup>
    <mo>=</mo>
    <mfrac><msub><mi>L</mi><mi>i</mi></msub><mrow><msub><mi>P</mi><mi>i</mi></msub><mo>&#x2212;</mo><mn>1</mn></mrow></mfrac>
  </mrow>
</math>
P_i = |~ L_i / p ~| + 1,  p'_i = L_i / (P_i - 1)
pi = Ceiling[L/p] + 1; pitchActual = L/(pi - 1)
P[i] := ceil(L[i]/p) + 1;  pActual[i] := L[i]/(P[i] - 1);
P = ceil(L./p) + 1; pActual = L./(P - 1);
P_i = ⌈L_i/p⌉ + 1, p'_i = L_i/(P_i − 1)
Rails and total rail length
R = t × q,  ℓR = t × L
R = t q,\quad \ell_{R} = t L
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
  <mrow>
    <mi>R</mi>
    <mo>=</mo>
    <mi>t</mi>
    <mo>&#xD7;</mo>
    <mi>q</mi>
    <mo>,</mo>
    <msub><mi>&#x2113;</mi><mi>R</mi></msub>
    <mo>=</mo>
    <mi>t</mi>
    <mo>&#xD7;</mo>
    <mi>L</mi>
  </mrow>
</math>
R = t * q,  l_R = t * L
r = t q; lR = t l
R := t*q;  lR := t*L;
R = t*q; lR = t*L;
R = t × q, ℓ_R = t × L
Boards (vertical pickets and horizontal boards)
nᵢ = ⌈Lᵢ ÷ (b + s)⌉,  m = ⌈H ÷ (b + s)⌉,  Bᵢ = m × ⌈Lᵢ ÷ ℓ⌉
n_{i} = \left\lceil \frac{L_{i}}{b + s} \right\rceil,\quad m = \left\lceil \frac{H}{b + s} \right\rceil,\quad B_{i} = m \left\lceil \frac{L_{i}}{\ell} \right\rceil
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
  <mrow>
    <msub><mi>n</mi><mi>i</mi></msub>
    <mo>=</mo>
    <mo>&#x2308;</mo>
    <mfrac><msub><mi>L</mi><mi>i</mi></msub><mrow><mi>b</mi><mo>+</mo><mi>s</mi></mrow></mfrac>
    <mo>&#x2309;</mo>
    <mo>,</mo>
    <mi>m</mi>
    <mo>=</mo>
    <mo>&#x2308;</mo>
    <mfrac><mi>H</mi><mrow><mi>b</mi><mo>+</mo><mi>s</mi></mrow></mfrac>
    <mo>&#x2309;</mo>
    <mo>,</mo>
    <msub><mi>B</mi><mi>i</mi></msub>
    <mo>=</mo>
    <mi>m</mi>
    <mo>&#x2062;</mo>
    <mo>&#x2308;</mo>
    <mfrac><msub><mi>L</mi><mi>i</mi></msub><mi>&#x2113;</mi></mfrac>
    <mo>&#x2309;</mo>
  </mrow>
</math>
n_i = |~ L_i / (b + s) ~|,  m = |~ H / (b + s) ~|,  B_i = m |~ L_i / l ~|
n = Ceiling[L/(b + s)]; m = Ceiling[h/(b + s)]; bi = m Ceiling[L/len]
n[i] := ceil(L[i]/(b + s));  m := ceil(H/(b + s));  B[i] := m*ceil(L[i]/l);
n = ceil(L./(b + s)); m = ceil(H/(b + s)); B = m*ceil(L./len);
n_i = ⌈L_i/(b + s)⌉, m = ⌈H/(b + s)⌉, B_i = m⌈L_i/ℓ⌉
Boards to buy with waste
B′ = ⌈B × (1 + r/100)⌉
B' = \left\lceil B \left(1 + \frac{r}{100}\right) \right\rceil
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
  <mrow>
    <msup><mi>B</mi><mo>&#x2032;</mo></msup>
    <mo>=</mo>
    <mo>&#x2308;</mo>
    <mi>B</mi>
    <mrow><mo>(</mo><mn>1</mn><mo>+</mo><mfrac><mi>r</mi><mn>100</mn></mfrac><mo>)</mo></mrow>
    <mo>&#x2309;</mo>
  </mrow>
</math>
B' = |~ B (1 + r/100) ~|
bBuy = Ceiling[b (1 + r/100)]
Bbuy := ceil(B*(1 + r/100));
Bbuy = ceil(B*(1 + r/100));
B′ = ⌈B(1 + r/100)⌉
Working backward: length the panels you have will cover
Lmax = N × w,  P = N + 1
L_{\max} = N w,\quad P = N + 1
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
  <mrow>
    <msub><mi>L</mi><mi>max</mi></msub>
    <mo>=</mo>
    <mi>N</mi>
    <mo>&#xD7;</mo>
    <mi>w</mi>
    <mo>,</mo>
    <mi>P</mi>
    <mo>=</mo>
    <mi>N</mi>
    <mo>+</mo>
    <mn>1</mn>
  </mrow>
</math>
L_max = N * w,  P = N + 1
lMax = n w; p = n + 1
Lmax := N*w;  P := N + 1;
Lmax = N*w; P = N + 1;
L_max = N × w, P = N + 1
Estimated cost
C = u × Q,  T = C₁ + C₂ + C₃ + C₄
C = u Q,\quad T = C_{1} + C_{2} + C_{3} + C_{4}
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
  <mrow>
    <mi>C</mi>
    <mo>=</mo>
    <mi>u</mi>
    <mo>&#xD7;</mo>
    <mi>Q</mi>
    <mo>,</mo>
    <mi>T</mi>
    <mo>=</mo>
    <msub><mi>C</mi><mn>1</mn></msub>
    <mo>+</mo>
    <msub><mi>C</mi><mn>2</mn></msub>
    <mo>+</mo>
    <msub><mi>C</mi><mn>3</mn></msub>
    <mo>+</mo>
    <msub><mi>C</mi><mn>4</mn></msub>
  </mrow>
</math>
C = u * Q,  T = C_1 + C_2 + C_3 + C_4
c = u q; t = c1 + c2 + c3 + c4
C := u*Q;  T := C1 + C2 + C3 + C4;
C = u*Q; T = C1 + C2 + C3 + C4;
C = u × Q, T = C_1 + C_2 + C_3 + C_4

How to have ChatGPT  do the calculation

You are an assistant for estimating fence materials. Do the following calculation by actually running Python code, and base your answer only on the numbers from the run (do not answer from mental math or guesses).

I am building an L-shaped vinyl fence with side 1 of 50 ft and side 2 of 30 ft, using 8 ft panels (posts 96 in on center). The corner uses one shared corner post. Each post is set in 1.2 ft³ of concrete, and an 80 lb bag makes about 0.6 ft³.
Find each of the following.
1. The panels on each side (side length in inches ÷ 96, rounded up) and the total, and how wide to cut the last panel on each side
2. The posts with one shared corner post (total panels + 1), and with 2 posts at the corner (panels + 1 for each side, added up)
3. The footings (same as the posts), the total concrete, and the 80 lb bags needed (rounded up)
4. For a wood fence on the same sides instead: the posts on each side with posts no more than 96 in apart, the actual spacing, the rails for 3 rows, and the 1×6 pickets (5.5 in wide) with a 1/4 in gap, net and with a 5% waste factor

Show the formulas you used and the numbers from the run.

How to Use
  1. 1
    Enter your numbers
    Type the numbers you want to calculate with into the input fields
  2. 2
    Calculate
    Press the "Calculate" button
  3. 3
    Check the result
    The result appears on the spot. The same page also explains the idea behind the calculation and the formula
  DataChef Features
Easy and Free
Unlimited conversions for free.
No technical knowledge required.
Intuitive and user-friendly operation.
No Registration Required
Available immediately after access.
Can be used without registering personal information.
Safe and Secure
Fully SSL encrypted communication.
Automatic file deletion by clicking "download".
Fast
High-speed site access
and rapid file conversion.
No Watermark
No watermark.
No attribution required.
Commercial Use Available
Free for commercial use.
No need to contact us for commercial use permission.