Home › Construction & Home › Fence Calculator
Fence Calculator
Estimates the posts, rails and pickets for a straight run of wooden fence from the total length, the maximum post spacing, the number and width of gates, the rails per section and the picket width plus gap.
When to use
You need a material list (posts, rails, pickets) for a picket, privacy or post-and-rail fence of a known length.
Do not use when: You need concrete for the post holes (use cylinder for the hole volume and concrete-slab for bags), or the fence is chain-link or panel fencing sold per panel (divide the length by the panel width instead).
Formula
fence_length = total_length − gates × gate_width; sections = ceil(fence_length / post_spacing); posts = sections + gates + 1; actual_spacing = fence_length / sections; rails = sections × rails_per_section; pickets = ceil(fence_length / (picket_width + picket_gap)).
Assumes one straight run with posts at both ends and gates as extra bays; for a closed loop (fence all the way round) subtract 1 post, and add one post per corner or change of direction. Gate hardware, post concrete and cap rails are not included.
Inputs
| Parameter | Type | Unit | Required | Description |
|---|---|---|---|---|
unit_system | enum: metric | imperial | default metric | Unit system of the length inputs (metric: m / cm / mm; imperial: ft / in). Outputs are reported in both systems. | |
total_length | number | m or ft | yes | Overall length of the fence line including gate openings (m or ft). Range: > 0, ≤ 100000 |
post_spacing | number | m or ft | no | Maximum centre-to-centre distance between posts; sections are spaced evenly at or below this. Default 2.4 m (metric) or 8 ft (imperial). Range: > 0, ≤ 20 |
gates | integer | default 0 | Number of gate openings in the run; each takes a bay between two posts. Range: ≥ 0, ≤ 50 | |
gate_width | number | m or ft | no | Width of each gate opening. Default 1 m (metric) or 3 ft (imperial). Range: > 0, ≤ 10 |
rails_per_section | integer | default 2 | Horizontal rails between each pair of posts: 2 for fences up to about 1.2 m / 4 ft, 3 for 1.8 m / 6 ft privacy fences. Range: ≥ 1, ≤ 5 | |
picket_width | number | mm or in | no | Width of one picket/board in millimetres (metric) or inches (imperial). Optional; enables the picket count. Range: > 0, ≤ 1000 |
picket_gap | number | mm or in | default 0 | Gap between pickets (0 for a solid privacy fence), in mm or in. Range: ≥ 0, ≤ 1000 |
Outputs
| Output | Type | Unit | Description |
|---|---|---|---|
fence_length_m | number | m | total_length − gates × gate_width. |
fence_length_ft | number | ft | Same length in feet. |
sections | integer | ceil(fence_length / post_spacing). | |
posts | integer | sections + gates + 1 (straight run; gate posts included). | |
actual_post_spacing_m | number | m | fence_length / sections. |
actual_post_spacing_ft | number | ft | Actual spacing in feet. |
rails | integer | sections × rails_per_section. | |
pickets | integer | ceil(fence_length / (picket_width + picket_gap)); only when picket_width is given. |
Example
100 ft, 8 ft spacing, one 4 ft gate, 2 rails, 5.5 in pickets with 0.5 in gap: {"unit_system":"imperial","total_length":100,"post_spacing":8,"gates":1,"gate_width":4,"rails_per_section":2,"picket_width":5.5,"picket_gap":0.5} → {"fence_length_ft":96,"fence_length_m":29.26,"sections":12,"posts":14,"actual_post_spacing_ft":8,"rails":24,"pickets":192}
30 m, 2.4 m spacing, no gate, 3 rails, 90 mm pickets with 10 mm gap: {"unit_system":"metric","total_length":30,"post_spacing":2.4,"gates":0,"rails_per_section":3,"picket_width":90,"picket_gap":10} → {"fence_length_m":30,"sections":13,"posts":14,"actual_post_spacing_m":2.308,"actual_post_spacing_ft":7.571,"rails":39,"pickets":300}
GET https://tttkmbb.com/api/v1/calculate/fence?unit_system=imperial&total_length=100&post_spacing=8&gates=1&gate_width=4&rails_per_section=2&picket_width=5.5&picket_gap=0.5
Machine access
- API:
GET https://tttkmbb.com/api/v1/calculate/fence(query parameters) orPOSTwith a JSON body{"inputs": {...}} - Schema: https://tttkmbb.com/api/v1/calculators/fence · Markdown: https://tttkmbb.com/construction/fence.md · JSON definition: https://tttkmbb.com/construction/fence.json
- MCP: server
https://tttkmbb.com/mcp, toolrun_calculator with calculator_id="fence" - OpenAPI operationId:
estimate_fence_materials - Freshness:
static. Authentication: none. Rate limit: fair use (see rate limits).
Sources
FAQ
How deep should posts go?
About one third of the post length, below the local frost line: a 1.8 m (6 ft) fence typically uses 2.4 m (8 ft) posts set 60 cm (2 ft) deep in concrete.
Why are the actual spacings smaller than the maximum?
The run is divided into equal sections so that no bay exceeds post_spacing; e.g. 30 m at a 2.4 m maximum needs 13 sections of 2.31 m.
Related calculators
- Decking Calculator — Boards and joists for a deck alongside the fence.
- Concrete Slab Calculator — Bags of concrete for post footings.
- Cylinder Calculator — Volume of a round post hole.