By Zencalcy Editorial TeamLast reviewed About us
For a rectangular enclosure the fence length is simply twice the sum of the sides — but the post count depends on spacing around the whole loop, and gates interrupt it. This calculator gives the perimeter, the posts at your spacing and the rails.
Perimeter and post count for a rectangular enclosure.
Perimeter = 2 × (L + W) Posts = ⌈perimeter ÷ spacing⌉
Unlike a straight run, a closed loop has the same number of posts as spaces. Each gate needs two posts and removes one bay of rails.
| Symbol | Meaning |
|---|---|
| L, W | Length and width of the enclosure. |
| P | Fence perimeter. |
Perimeter is 160 ft, so 20 posts and 20 bays — 40 rails for a two-rail fence.
Continue with the Paint Calculator, Wallpaper Calculator, Tile Calculator, or the Flooring Calculator — or browse more home & garden projects and all construction calculators.
At 8 ft spacing, 20 posts. Add two per gate.
Results use standard construction estimating arithmetic: volumes from measured area and depth, unit weights from published material densities, and code-referenced spans or clearances where the page names a code. Quantities are rounded up to whole saleable units and include the stated waste allowance. These tools are planning aids, not structural design, and do not replace a licensed engineer, a local code check, or a contractor's site measurement.
Reference material used to build and check this calculator:
Last reviewed: September 2026. See how we build and check every tool on the about page.
Estimate decking boards by length, screws, hidden fasteners and waste
Calculate concrete blocks needed for wall construction
Calculate full deck materials list including boards, joists, beams, posts, and cost estimates
Price hardwood the way the lumber yard does — by board footage.
Turn measured dimensions into the cubic yards concrete and gravel are sold in.
How many gallons it takes to cover an area at a given depth.
Content updated: September 2026