How to Measure for a Fence: Posts, Sections, Corners and Gates

How to count posts, sections, rails and pickets for a fence that goes around a yard, why corner posts are shared and how a gate changes the count, with a top-down diagram.

Written and last reviewed November 4, 2026 by Kevin.

A fence looks simple, but three things trip people up when they count materials: corner posts that belong to two sides, gates that add posts, and sections that must be rounded up on every side. This guide walks through a fence around a yard so the numbers you take to the store are right.

Start with a top-down sketch

  1. Draw the fence line as seen from above and mark every corner, every gate and anything the line has to go around.
  2. Measure each straight run along the line and write its length on the sketch. Use stakes and string to keep the line straight on a large yard.
  3. Decide how far apart the posts will be. Use the spacing in your plan or in your fence maker's instructions; it depends on the product.
  4. Treat each straight run as its own piece. A change of direction starts a new run.

The three rules

  1. Sections are rounded up on each run. A 30 ft run with posts 8 ft apart needs 30 ÷ 8 = 3.75, so 4 sections. You cannot buy three-quarters of a section.
  2. A straight run has one more post than sections. Four sections need five posts, because both ends have a post.
  3. A corner post is shared. It is the last post of one run and the first of the next, so count it once. For a closed fence around a yard, the number of posts equals the number of sections.

Because sections are rounded up and then spaced evenly, the real distance between posts is a little less than the maximum you chose. A 30 ft run in 4 sections has posts 7.5 ft apart.

Top-down view of a 40 by 30 foot fence with one gate A rectangular fence with posts at every corner. The top side has five sections and a 4 foot gate at its right end, the right side has four sections, the bottom side five and the left side four. There are 19 posts in total. gate 4 ft 40 ft: 36 ft of fence (5 sections) + 4 ft gate 40 ft: 5 sections 30 ft 4 sections 30 ft 4 sections corner post line post gate post
Add up the posts in the drawing: 19. The calculation below gives the same number.

Worked example: a 40 × 30 ft yard

Posts 8 ft apart, so each side is rounded up on its own: the 40 ft sides need 5 sections each and the 30 ft sides need 4. That is 5 + 4 + 5 + 4 = 18 sections.

Counting each side with its own end posts gives 6 + 5 + 6 + 5 = 22 posts, but the four corner posts were each counted twice. Subtract 4 and you get 18 posts, the same as the number of sections.

With two rails per section that is 36 rails. With 5½ in pickets, a ½ in gap and 5 % extra, adding up each side gives 294 pickets.

Adding a gate

A gate needs a post on each side of its opening. Put a 4 ft gate at the end of a 40 ft side: the fence on that side is 36 ft, which is 5 sections and 7 posts, and the whole yard becomes 18 sections and 19 posts with 286 pickets. The opening itself needs no pickets, but you still need to buy the gate and its hardware.

A gate in the middle of a side can cost one more section. Put the same 4 ft gate in the middle of the 40 ft side and you have two 18 ft runs. Each rounds up to 3 sections, so that side needs 6 sections and 8 posts instead of 5 and 7. The Fence Calculator treats the fenced length as a single run, so calculate the pieces on each side of a mid-run gate separately.

Common mistakes

This guide measures along a level line. On a slope, ask your fence maker how panels or pickets follow the ground.

Frequently asked questions

How far apart should fence posts be?

It depends on the fence style and the manufacturer, so use the spacing in your plan or the product instructions. The calculators take whatever spacing you enter.

Do I count the gate as a section?

No. The gate opening is not part of the fenced length. The fence on each side of it is, and each side of the opening needs a post.

How do I estimate the concrete for the posts?

Take the number of posts and the size of the hole from your plan, find the volume of one hole in cubic feet and multiply. The cubic yards guide explains the conversions.

Sources

See our editorial policy for how guides are written, reviewed and corrected.

Calculators for this guide

More guides