# 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.

- Calculator id: `fence` · Category: Construction & Home (`construction`) · Tool name: `estimate_fence_materials`
- Canonical page: https://tttkmbb.com/construction/fence · This document: https://tttkmbb.com/construction/fence.md · JSON definition: https://tttkmbb.com/construction/fence.json

## Purpose

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.

**Use when:** 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).

## Input

| Parameter | Type | Unit | Required | Description |
| --- | --- | --- | --- | --- |
| `unit_system` | enum: metric \| imperial |  | optional, 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 | required | Overall length of the fence line including gate openings (m or ft). (> 0, max 100000) |
| `post_spacing` | number | m or ft | optional | Maximum centre-to-centre distance between posts; sections are spaced evenly at or below this. Default 2.4 m (metric) or 8 ft (imperial). (> 0, max 20) |
| `gates` | integer |  | optional, default 0 | Number of gate openings in the run; each takes a bay between two posts. (min 0, max 50) |
| `gate_width` | number | m or ft | optional | Width of each gate opening. Default 1 m (metric) or 3 ft (imperial). (> 0, max 10) |
| `rails_per_section` | integer |  | optional, 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. (min 1, max 5) |
| `picket_width` | number | mm or in | optional | Width of one picket/board in millimetres (metric) or inches (imperial). Optional; enables the picket count. (> 0, max 1000) |
| `picket_gap` | number | mm or in | optional, default 0 | Gap between pickets (0 for a solid privacy fence), in mm or in. (min 0, max 1000) |

## Output

| Field | 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. |

## 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.

## Data Sources

- Lowe's – How to build a wood fence (posts 6–8 ft on centre, 3 rails for 6 ft pickets) — https://www.lowes.com/n/how-to/install-a-wood-fence (reference, retrieved 2026-09-23)

Data freshness: `static`. Deterministic formula with fixed constants; results never go stale. Inputs supplied by the caller determine the output.

## API

- `GET https://tttkmbb.com/api/v1/calculate/fence?total_length=…`
- `POST https://tttkmbb.com/api/v1/calculate/fence` with JSON body `{"inputs": {…}}`
- Response: unified envelope (`success`, `request`, `result.values`, `result.units`, `sources`, `freshness`, `timestamp`, `next_actions`, `links`); see https://tttkmbb.com/docs/response-format.md
- Schema: https://tttkmbb.com/api/v1/calculators/fence · OpenAPI operationId `estimate_fence_materials` in https://tttkmbb.com/openapi.json
- Authentication: none. Rate limit: fair use, see https://tttkmbb.com/docs/rate-limits.md.

## MCP

- Server: `https://tttkmbb.com/mcp` (Streamable HTTP, JSON-RPC 2.0, no auth)
- Tool:  `run_calculator` with `{"calculator_id": "fence", "inputs": {…}}`

## Example

- 100 ft, 8 ft spacing, one 4 ft gate, 2 rails, 5.5 in pickets with 0.5 in gap: inputs `{"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: inputs `{"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
```

## Limitations

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). 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. All values are computed from the formula above; no measurement or live data is involved.

## 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

- [Decking Calculator](https://tttkmbb.com/construction/decking.md) — Boards and joists for a deck alongside the fence.
- [Concrete Slab Calculator](https://tttkmbb.com/construction/concrete-slab.md) — Bags of concrete for post footings.
- [Cylinder Calculator](https://tttkmbb.com/geometry/cylinder.md) — Volume of a round post hole.
