How to use the fence calculator
This fence calculator turns the layout of a fence into a shopping list. It places the posts the way a fence is built, with an end, corner or gate post wherever the fence starts, stops or turns, and line posts in between; it counts the pickets, boards, rails, panels, chain-link fabric or wire for the style you choose; and it works out the concrete for the post holes. All of the math runs in your browser.
- Choose the style. Under Fence style, pick vertical boards (a privacy or picket fence), horizontal boards, split rail, pre-built panels, chain link, or a wire fence such as woven, welded or field fence.
- Enter the sides. Type the length of each straight side in order, add a side for every turn, and tick The fence closes on itself if the last side meets the first. Add each gate, the side it is in and its width, and the fence height.
- Set the posts and holes. Enter the largest post spacing from your plan (or the panel width or rail length), the post size, and the hole diameter and depth. Choose which posts are set in concrete and enter the yield printed on your concrete bags.
- Fill in the style details. Board width and gap or overlap, rails per section, roll lengths, top-rail sticks or clips, and the fasteners you plan to use.
- Read the materials list. Add prices if you want a cost. Copy the results, download them as a CSV file or print them.
Every length field has its own unit, and you can type 12' 6", 150 in or 3.6 m. Switch Units to Metric to see lengths in meters and volumes in cubic meters. The calculator remembers your last entries on this device.
How to measure for a fence
- Walk the fence line. Mark where the fence starts, every place it changes direction and where it ends. Each straight run between two of those points is one side.
- Measure each side along the ground where the posts will go, from corner to corner. The calculator takes the length center to center of the end posts, so you do not need to subtract the posts.
- Mark the gates. Note the opening each gate needs, post to post, and the side it is in. The calculator takes it out of that side and puts a gate post on each side of it.
- Decide where the fence ends. A fence that runs from the house around the yard and back to the house has two ends. One that encloses a space all the way around closes on itself and has no ends, only corners.
Before you set the line, find the property line: a survey or your property records show it, and a fence built on the wrong side of it can become a dispute. For the area inside the fence, use the square footage calculator.
How to calculate fence materials
The calculator follows the order a fence goes up in, from the posts to the boards:
fence length = sum of the sides − gate widths
sections = stretch ÷ largest post spacing, rounded up (each stretch runs between end, corner and gate posts)
line posts = sections − 1, in every stretch
pickets = (stretch + gap) ÷ (picket width + gap), rounded up
rails = sections × rails per section
concrete = (hole area − post area) × depth in the hole, per post
- Measure each side. Measure every straight side of the fence line in order, from corner to corner, and note whether the fence closes on itself.
- Mark the gates. Subtract each gate's width from its side. What is left is fence, split evenly on both sides of the gate.
- Place the posts. Put a post at each end, at each corner and on each side of every gate. Divide each stretch between those posts by the largest post spacing, round up for the number of sections, and add line posts between the sections.
- Count the boards or panels. For each stretch, divide its length plus one gap by the board width plus the gap and round up, or count one panel per section. Add a few percent for waste.
- Add the rails, fabric or wire. Multiply the sections by the rails per section, or divide the fence length by the roll length for chain-link fabric or wire.
- Work out the concrete. For each post hole, take the hole's area minus the post's, multiply by the depth below the post bottom and divide by the yield on the bag.
Example: a 6 ft privacy fence on three sides, 60, 40 and 60 ft long, with a 4 ft gate in the 40 ft side and posts no more than 8 ft apart. The fence is 156 ft long. It needs 6 end, corner and gate posts and 18 line posts, 24 in all, for 22 sections. Boards 5 1/2 in wide with no gap take 342 boards, or 360 boards with 5% for waste, and three rails per section take 66 rails. With 10 in holes 30 in deep, the posts take 51 bags of concrete.
Fence posts: how many and how far apart
A fence has two kinds of posts. Terminal posts stand where the fence starts or stops: at each end, at each corner, and on both sides of every gate. They take the pull of the fence and the weight of the gates. Line posts stand in between, at most your post spacing apart. The calculator splits every stretch between two terminal posts into equal sections no longer than the spacing you enter, so each section is the same length and rails are cut to one size.
There is no single correct post spacing. For panels it is the panel width, for split rail the rail length, and for boards and wire it comes from your plan or the product instructions. For chain link, one federal construction specification, UFGS 32 31 13, says "Provide line posts spaced equidistantly apart, not exceeding 10 feet on center." That is a specification for government projects, not a rule for homes, but the calculator uses 10 ft as its chain-link starting value.
| Fence length | Posts at most 6 ft apart | Posts at most 8 ft apart | Posts at most 10 ft apart |
|---|---|---|---|
| 50 ft | 10 | 8 | 6 |
| 100 ft | 18 | 14 | 11 |
| 150 ft | 26 | 20 | 16 |
| 200 ft | 35 | 26 | 21 |
Corners and gates add posts. A straight 100 ft fence with posts no more than 8 ft apart has 13 sections and 14 posts. The example fence, which turns two corners and has a gate, needs 24 posts for its 156 ft. A rectangle 50 by 30 ft that closes on itself, with one 4 ft gate, has no ends: it needs 6 corner and gate posts and 22 posts in all.
Each post's length is the fence height plus the depth it sits in the hole. For the example, 6 ft above the ground and a 30 in hole make posts at least 8 ft 6 in long. The American Softwood Lumber Standard, PS 20, lists a nominal 4 in width at 3 1/2 in when dry, so a 4 × 4 post is 3 1/2 in square, the calculator's default post size.
Pickets and boards: privacy, picket and board on board
For a fence of vertical boards, the boards in each stretch are counted the way they are nailed up: one board, then a gap, then the next, until the stretch is covered. That is the stretch plus one gap, divided by the board width plus the gap, rounded up; the last board may be ripped narrower. PS 20 lists a board of 6 in nominal width at 5 1/2 in dry, which is the default board width. A solid privacy fence has no gap; a picket fence leaves one.
A straight 100 ft privacy fence of 5 1/2 in boards takes 219 boards. With 2 in gaps, as on a picket fence, it takes 161 pickets. Built board on board, with boards alternating front and back and each overlapping the next by 1 1/2 in, it takes 300. Board on board leaves no see-through gaps, at the cost of more boards: each board after the first adds only its width minus the overlap.
On the example fence, board on board takes 468 boards before waste, against 342 side by side. The waste allowance covers split boards and mistakes; the cuts are already counted.
A horizontal board fence runs boards from post to post instead. The calculator counts the rows that fill the height, the height plus one gap divided by the board width plus the gap, and cuts one piece per row in every section. With 5 1/2 in boards and 1/4 in gaps, the example fence has 13 rows and 286 pieces, which pack into 301 boards 8 ft long with 5% for waste. Offcuts are reused where they fit, longest piece first.
Fence rails
Rails, sometimes called stringers or backer rails, run between the posts and carry the boards. The calculator multiplies the sections by the rails per section that your plan calls for; fences differ, so it does not pick a number for you. Each rail spans one section, post to post, and the pieces are packed into the rail length you buy, so two short sections can share one long rail. Auto tries every length in the list and keeps the one that buys the least rail.
The example fence has 22 sections, 16 of them 7 ft 6 in long and 6 of them 6 ft long. With three rails each that is 66 pieces, and from 8 ft rails it takes 66 rails, one per piece. The boards are fastened to every rail and the rails to the posts: with two fasteners per board per rail and two per rail end, that is 2,316 nails or screws, or 3 boxes of 1,000.
Fence panels and split rail
Pre-built panels of wood or vinyl come in a fixed width, so the post spacing is the panel width. The calculator counts one panel per section and cuts the last panel of a stretch to fit. With 8 ft panels the example fence takes 22 panels, 4 of them cut, and the same 24 posts. Panels that slide into slotted posts may not take a cut, so check the panel instructions; for brackets or screws, enter the number per panel.
A split rail fence has rails that fit into holes in the posts, so the post spacing is the rail length and there are no fasteners. With 10 ft rails and three rails per section, the example layout has 16 sections, 48 rails and 18 posts. End and corner posts are drilled on one side or two, so tell your supplier how many of each you need.
Chain-link fence materials
A chain-link fence is fabric stretched between terminal posts, held up by line posts and a top rail. The calculator follows the parts one federal specification for chain-link fences lists. Section UFGS 32 31 13 calls for "fabric in single lengths between stretch bars", stretcher bars "secured to posts with metal bands spaced 15 inches on center", and wire for "tying fabric to line posts, spaced 12 inches on center. For tying fabric to rails and braces, space wire ties 24 inches on center." Those are the calculator's starting values, and you can change them.
- Fabric is the fence length, in rolls of the length you enter. Pieces of different rolls can be joined, so the rolls are the total length divided by the roll length, rounded up.
- Tension bars (stretcher bars) hold each end of the fabric: one at an end or gate post, two at a corner, where the fabric stops on both sides. Each bar takes tension bands spaced as you enter.
- Top rail runs from terminal post to terminal post through loop caps on the line posts, in sticks of the length you enter. Each rail end at a terminal post takes a brace band and a rail end cup.
- Ties fasten the fabric to the line posts and the top rail, and an optional bottom tension wire takes hog rings.
A 4 ft chain-link fence on the example layout, with line posts no more than 10 ft apart, 50 ft rolls and top-rail sticks 10 ft 6 in long, takes 4 rolls of fabric, 16 sticks of top rail, 6 terminal posts and 12 line posts, 8 tension bars with 32 tension bands, 12 loop caps and 126 ties. The same federal specification (UFGS 32 31 13) adds: "Do not exceed 500 feet on straight runs between braced posts." On longer straight runs, plan pull posts with your supplier; the calculator does not add them.
Wire fences: woven, welded and field fence
For a wire fence, the calculator counts the wire by the roll, the line posts as steel T-posts driven between wood or steel terminal posts, and the clips that hold the wire to each T-post. Barbed wire strands, if you add them, are counted by their total length in rolls of the length you enter.
Terminal posts of a wire fence are braced against the pull of the wire. With H-braces on, the calculator adds a brace post and a brace rail beside each end and gate post and one in each direction at every corner. On the example layout, a 4 ft wire fence with T-posts no more than 10 ft apart and 330 ft rolls takes 1 roll of wire, 12 T-posts with 60 clips, and 8 H-braces, so 26 posts in all. Two strands of barbed wire add 312 ft of wire, 1 roll. The bracing a fence needs depends on its length, the wire and the ground, so follow your plan.
Fence post depth and concrete
How deep to set a post depends on where you live, the soil, the height of the fence, the gates and the wind, so the calculator takes the hole depth from you and does not suggest one. In cold climates, frost can lift posts that are set too shallow. The 2024 International Residential Code (IRC) leaves the frost depth to each community: under Table R301.2, "The jurisdiction shall fill in the frost line depth column with the minimum depth of footing below finish grade." That table is written for building footings, not fences, but it is where your building department records the local frost depth; a local extension office can also help. For comparison, the federal chain-link specification (UFGS 32 31 13) says "Set bottom of each post not less than 36 inches below finished grade when in firm, undisturbed soil. Set posts deeper, as required, in soft and problem soils and for heavy, lateral loads." Local codes, zoning and amendments govern; check with your building or zoning department.
Each hole holds a cylinder of concrete with the post standing in it. The calculator takes the hole's area, π × (diameter ÷ 2)², subtracts the post's area, and multiplies by the depth of concrete, the hole depth minus any gravel at the bottom. It then adds your extra percentage for uneven holes and divides by the yield printed on the bag.
A 10 in hole 30 in deep around a 4 × 4 post holds 1.15 cu ft of concrete. If your bags say they make 0.6 cu ft each, that is 1.9 bags, so 2 per post. The example's 24 posts take 27.62 cu ft; with 10% extra, 30.38 cu ft, or 1.13 cubic yards, which is 51 bags. Setting only the end, corner and gate posts in concrete would take 13 bags. Read the yield on your bag: it is not the bag's weight, and it differs from mix to mix. For a large pour, compare the cubic yards with ready-mix delivery using the cubic yard calculator.
Some builders put a layer of gravel at the bottom of each hole for the post to stand on. Enter its depth and the calculator counts it and shortens the concrete to match: a 34 in hole with 4 in of gravel keeps the post 30 in deep and takes 0.18 cu ft of gravel per hole, 4.36 cu ft for the example, or 9 bags of 0.5 cu ft. For gravel by the ton or the cubic yard, see the gravel calculator.
Gates
Add a gate for every opening and enter the opening width, post to post. The calculator subtracts it from its side, splits the rest of the side evenly on both sides of the gate and puts a gate post at each edge. A gate at the very end of a side shares its post with the corner, and two gates side by side share the post between them. Gates are listed by width, with the hinges per gate you enter and one latch each. Gate posts carry the gate's weight and swing, so your plan may call for a heavier post there: enter that size as the end, corner and gate post size.
Before you dig: call 811
Fence post holes go deep enough to reach buried gas, electric, water and communication lines. The national call-before-you-dig service says: "811 is the free national before-you-dig service. Anyone who plans to dig should contact 811 or go to their state 811 center's website before digging to request that the approximate location of buried utilities be marked with paint or flags so that you don't unintentionally dig into an underground utility line." It adds that you should contact 811 "a few business days before you begin any digging, including common projects like planting trees and shrubs or installing fences and mailboxes," and that "Some utilities can be buried just inches below the surface". Dig carefully around the marks, and move a post if it lands on one. Details and your state's 811 center are at call811.com.
Fence permits and height limits
Whether a fence needs a permit, and how tall it may be, is decided locally. Many places in the United States adopt the International Residential Code, published by the International Code Council, often with amendments. Under section R105.2 of the 2024 IRC, "Work exempt from permit," permits are not required for "Fences not over 7 feet (2134 mm) high," and the same section warns that "Exemption from permit requirements of this code shall not be deemed to grant authorization for any work to be done in any manner in violation of the provisions of this code or any other laws or ordinances of this jurisdiction." Height limits, setbacks, front-yard and corner-lot rules usually come from the local zoning ordinance, and a homeowners association can add its own rules. Fences around pools have separate rules that this calculator does not cover. Local codes, zoning and amendments govern; check with your building or zoning department.
Fence cost
Prices for lumber, vinyl, steel and concrete change from place to place and week to week, so the calculator fills in none. Enter what your supplier charges for each item, each, per bag, per roll or per box, and every line of the materials list gets a cost, with the total of the prices you entered underneath. Leave a price blank to skip that line. Labor, delivery, permits, tool rental and stain or paint are not included; add them yourself. The CSV download opens in any spreadsheet if you want to compare quotes or styles.
Metric fences
Switch Units to Metric to see lengths in meters and volumes in cubic meters. Rail and board lengths then range from 1.8 m to 4.8 m in 0.6 m steps; check what your supplier stocks. Type lengths in meters or centimeters, and enter the bag yield in liters if that is how the bag states it.
The conversions are exact: since 1959, an inch is exactly 2.54 centimeters and a foot exactly 0.3048 meters, as the National Institute of Standards and Technology (NIST) lists in Handbook 44, Appendix C and Special Publication 811. So a cubic foot is exactly 28.316846592 liters and a cubic yard 27 cubic feet. The example fence of 156 ft is 47.55 m long.
How we calculate
Every figure in the tool and on this page comes from the same code, and the examples above are checked against it automatically.
- Lengths. Every measurement is converted to feet first: inches ÷ 12, centimeters ÷ 30.48, meters ÷ 0.3048, the exact NIST definitions.
- Layout. Fence length = sum of the sides − gate widths. A side with gates is split into equal stretches around them. Terminal posts stand at the ends, the corners and both sides of each gate, merged where they meet.
- Posts. Sections per stretch = stretch ÷ spacing, rounded up; line posts = sections − 1. Post length = height + hole depth − gravel.
- Boards. Side by side: (stretch + gap) ÷ (width + gap), rounded up. Board on board: (stretch − overlap) ÷ (width − overlap), rounded up. Horizontal: rows = (height + gap) ÷ (width + gap), rounded up, one piece per row per section. Boards to buy × (1 + waste ÷ 100), rounded up.
- Rails and boards from stock. Every piece is placed, longest first, into the rail or board with the least length left that still holds it; a new one is opened only when none does.
- Chain link and wire. Rolls = fence length ÷ roll length, rounded up. Tension bars = fabric ends at terminal posts; bands per bar = height ÷ band spacing, rounded up; ties per line post = height ÷ tie spacing, rounded up, plus top rail ÷ tie spacing per stretch.
- Concrete. (π × (diameter ÷ 2)² − post area) × (hole depth − gravel), per post set in concrete, × (1 + extra ÷ 100); bags = that ÷ the bag yield, rounded up.
- Cost. Each quantity × your price. Nothing is filled in for you, because prices vary from place to place.
The calculator does not size posts, rails, footings or gates, choose a post depth, account for slopes or stepped panels, or check zoning, setbacks or property lines.
Your measurements stay on your device
The calculator runs entirely as JavaScript in your browser tab. Nothing you enter is uploaded: the page's Content-Security-Policy allows connections only back to this site, and the tool has no code that sends anything anywhere. It remembers your last measurements and settings in your browser's local storage, on your device only. There is no account and no cookie.
Frequently asked questions
How many fence posts do I need?
Put a post at each end, each corner and each side of every gate. Then divide each stretch between those posts by your largest post spacing, round up for the sections, and add one line post fewer than the sections. A straight 100 ft fence with posts no more than 8 ft apart has 13 sections and 14 posts.
How far apart should fence posts be?
There is no single rule. For panels the spacing is the panel width and for split rail the rail length; for boards and wire it comes from your plan or the product instructions. For chain link, one federal specification spaces line posts no more than 10 feet on center. The calculator splits each stretch into equal sections no longer than the spacing you enter.
How many pickets do I need for a 100 ft fence?
Divide the length plus one gap by the picket width plus the gap and round up. With 5 1/2 in pickets and 2 in gaps, a 100 ft fence takes 161 pickets; with no gap, as on a privacy fence, 219. Add a few percent for waste.
How many rails does a fence need?
Multiply the sections by the rails per section in your plan. The example fence has 22 sections, so with three rails each it takes 66 rail pieces, which the calculator fits into the rail length you buy.
How deep should fence posts be?
It depends on your frost depth, your soil, the height of the fence and the gates, so ask your building department or a local extension office. The calculator uses the hole depth you enter and makes each post that much longer than the fence is high. For comparison, one federal chain-link specification sets posts at least 36 inches below grade in firm soil.
How many bags of concrete do I need per fence post?
Divide the concrete in one hole, the hole's area minus the post's times the depth, by the yield printed on the bag. A 10 in hole 30 in deep around a 4 × 4 post holds 1.15 cu ft, so with bags that make 0.6 cu ft each it takes 1.9 bags: buy 2, plus some extra for uneven holes.
Should I put gravel at the bottom of a post hole?
Some builders do, for the post to stand on. It is optional in the calculator: enter the depth of gravel and it counts the gravel, keeps the post on top of it and shortens the concrete to match. Follow your plan and local guidance.
Do I need a permit to build a fence?
It depends on where you live. The 2024 IRC exempts fences not over 7 feet high from a building permit, but local amendments, zoning ordinances and homeowners associations often set their own height limits and rules. Check with your building or zoning department before you build.
Do I need to call 811 before digging fence post holes?
Yes. The national 811 service asks everyone who plans to dig, including for fences, to contact 811 or their state 811 center a few business days before digging, so buried utility lines can be marked. Then dig carefully around the marks.
How many rolls of chain-link fabric do I need?
Divide the fence length, without the gates, by the roll length and round up. The example fence of 156 ft takes 4 rolls of 50 ft. The calculator also counts the top rail, tension bars and bands, caps and ties.
How many boards do I need for a board-on-board fence?
Subtract the overlap from the stretch and divide by the board width minus the overlap, then round up. A straight 100 ft fence of 5 1/2 in boards overlapping by 1 1/2 in takes 300 boards before waste.
How do I estimate the cost of a fence?
Enter your supplier's price for each item in the Prices section: boards, rails, posts, panels, rolls, concrete bags, fasteners and gates. The calculator multiplies each by its quantity and adds up the lines you priced. Labor, delivery and permits are not included.
Sources
- International Code Council: 2024 International Residential Code, Chapter 1, Scope and Administration, section R105.2 Work exempt from permit: fences not over 7 feet high.
- International Code Council: 2024 International Residential Code, Chapter 3, Building Planning, Table R301.2 Climatic and geographic design criteria: the frost line depth each jurisdiction fills in.
- Unified Facilities Guide Specifications, Section 32 31 13, Chain Link Fences and Gates (November 2021), on the Whole Building Design Guide: post spacing, post setting, stretcher bars and bands, wire ties and bracing for federal projects.
- Common Ground Alliance: 811, the national before-you-dig service: contact 811 a few business days before digging, including for fences.
- NIST: Voluntary Product Standard PS 20-20, American Softwood Lumber Standard, Table 3: nominal and dressed sizes of boards and dimension lumber.
- National Institute of Standards and Technology: NIST Handbook 44 (2026), Appendix C, General Tables of Units of Measurement: 1 foot = 0.3048 meter and 1 inch = 2.54 centimeters, exactly.
- NIST Special Publication 811, Appendix B.9, Factors for units listed by kind of quantity: exact factors for the foot and the inch.
This is an educational tool, not engineering, building-code, surveying or construction advice. It counts materials; it does not design a fence. Post sizes, depths and spacing, footings and gates come from your plan, the product instructions, the rules where you live and your building or zoning department.