Fence Post Calculator

A fence post calculator divides the perimeter, 2 × (length + width), by post spacing and rounds up. A 40 × 30 ft yard at 8 ft spacing needs 18 posts.

You need—
Estimated cost—
Shop Fence Post at Home Depot →

How many fence posts do I need?

This fence post calculator works out the perimeter of a rectangular yard as 2 × (length + width), divides it by your post spacing, and rounds up. The formula is posts = 2 × (length + width) ÷ spacing, rounded up to a whole post. A 40 × 30 ft yard with posts 8 ft apart needs 18 posts.

Enter the two side lengths in feet, the spacing in feet (the third box), and the price per post. There is no waste toggle. Add gate posts and spares yourself.

Why there is no extra post for a closed fence

Picture walking the fence line and dropping a post every 8 ft. On a straight run, you need one more post at the far end than you have sections. Walk all the way around a yard, though, and the last section finishes at the post you started from. In a closed loop, posts and sections are the same number.

  1. Perimeter: 2 × (length + width)
  2. Sections: perimeter ÷ spacing
  3. Posts: sections rounded up to a whole number
  4. Cost: posts × price per post

Worked examples

  1. Backyard: 40 ft × 30 ft, 8 ft spacing, $8 per post
  • Perimeter: 2 × (40 + 30) = 140 ft
  • Posts: 140 ÷ 8 = 17.5, rounded up to 18 posts
  • Cost: 18 × $8 = $144.00
  1. Pasture or garden: 100 ft × 50 ft, 6 ft spacing, $8 per post
  • Perimeter: 2 × (100 + 50) = 300 ft
  • Posts: 300 ÷ 6 = 50 posts
  • Cost: 50 × $8 = $400.00

Check the count side by side

Real fences need a post at every corner, so each side is divided on its own. For a 60 × 45 ft yard at 8 ft spacing:

  • Calculator: 210 ÷ 8 = 26.25, rounded up to 27 posts
  • Side by side: 60 ÷ 8 = 7.5, rounded up to 8 sections; 45 ÷ 8 = 5.6, rounded up to 6 sections
  • Posts: 2 × (8 + 6) = 28 posts

When your sides are not exact multiples of the spacing, use the side-by-side count. It is the one you will actually build.

Fence post reference

Fence type Typical post spacing Common post
Wood privacy 6 to 8 ft 4 × 4 or 4 × 6 pressure-treated
Wood picket 6 to 8 ft 4 × 4 pressure-treated
Vinyl panel Set by panel width, often 6 or 8 ft 5 × 5 vinyl over a footing
Chain link Up to about 10 ft Galvanized steel tube
Wire / livestock Often 8 to 12 ft Steel T-posts with wood corners
Split rail Set by rail length, often 10 ft Mortised wood posts
Above-ground height Post length (one-third buried) Depth in ground
4 ft 6 ft 2 ft
6 ft 9 ft 3 ft
8 ft 12 ft 4 ft

Stock posts come in 8, 10, and 12 ft lengths. A 6 ft fence on 8 ft posts gets only 2 ft of embedment, so many builders step up to 10 ft posts.

How to measure the fence line

  • Measure where the fence will actually go, usually a few inches inside the property line. Confirm the line first.
  • Mark corners and gates before you count. Gate openings set fixed post positions. Space line posts evenly between them.
  • One side open? If the house forms one side, the fence is not a closed loop. Count each straight run as run ÷ spacing, rounded up, plus 1.

Common fence post mistakes

  • Forgetting gate posts. Gates need stout posts, often set deeper. Add two per gate.
  • Spacing wider than the rails. Rails and panels must land on a post. Match the spacing to your rail length.
  • Shallow holes. Use the fence post depth calculator, then size the concrete with the fence post concrete calculator.

For the whole fence, including rails and pickets, use the fence calculator or the fence picket calculator. For wire fencing, see the T-post calculator.

Embed this calculator on your site

Free to use. Paste this into your page's HTML. Please keep the link under the calculator.

Frequently asked questions

How many fence posts do I need?

For a closed rectangle, divide the perimeter by the post spacing and round up. A 40 × 30 ft yard has a 140 ft perimeter. At 8 ft spacing that is 140 ÷ 8 = 17.5, rounded up to 18 posts. Each section ends on a post, and the last section closes on the first post.

What's a typical post spacing?

Wood privacy and picket fences are commonly built with posts 6 to 8 ft apart, matching standard 8 ft rails and panels. Vinyl panels set their own spacing, often 6 or 8 ft. Chain link line posts often run up to 10 ft apart. Follow the panel or kit instructions.

Why isn't there a +1 in the formula?

A straight run needs one more post than sections: 4 panels in a line need 5 posts. A fence that closes on itself does not, because the last panel ends on the first post. This calculator handles a full rectangle, so posts equal sections.

Does this account for corner and gate posts?

Corners are not placed exactly. The calculator spaces posts evenly around the whole loop. If a side is not a multiple of your spacing, count posts side by side instead and you may need a post or two more. Gates need a heavier post on each side, so add them separately.

How deep should fence posts be set?

A common rule of thumb buries about one-third of the post's total length. Going below the frost line in cold areas keeps posts from heaving. Check local code or your HOA for minimums.

Estimates only. Verify quantities with your supplier before purchasing.