Fence gate calculator
Two 4-foot gate openings need 4 gate posts, 4 hinges and 2 latches: each opening gets a hinge post and a latch post, and leaves up to 5 feet wide get 2 hinges. Works for single and double gates. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Gates
- 2
- Gate width
- 4
- Leaves per gate
- 1
- Hinges per leaf
- 2
- Hinge width threshold
- 5
- Leaf width
- 4
A fence gate calculator turns the number of gate openings and each opening’s width into the hardware counts you need before you order posts, strap hinges, and latch kits.
Every opening is its own hardware package
The calculator treats each gate opening as a separate set of hardware. Every opening hangs between a hinge-side post and a latch-side post, so gate posts are always twice the number of openings, whether the gate is a single leaf or a pair that meets in the middle. Each opening also gets one latch assembly: a thumb latch on a single gate, a drop rod and latch kit on a double. Two openings 4 feet wide therefore give 4 gate posts, 2 latches and 8 feet of opening, which you can check against the fence run the gates replace.
How the hinge count is chosen
Hinges are openings times leaves times hinges per leaf. Unless you set the last figure yourself, the calculator divides the opening width by the number of leaves to find each leaf's width, then gives 2 hinges to a leaf up to 5 units wide and 3 to a wider one, the usual yard rule for heavier leaves that tend to sag. Keep the width and that limit in the same unit, because nothing is converted. It is a shopping list, not a structural check, and posts shared by back-to-back gates are adjusted on site.
How gate posts, hinges, and latches are counted from openings and width
Each gate opening on a fence is treated as an independent hardware package: one hinge-side post and one latch-side post, so gate posts always equal two times the number of openings. That model matches single swing gates and double swing gates at the take-off stage—both still hang from two end posts—while leaving shared posts between back-to-back openings as a site adjustment you make after the geometric count.
Leaves per gate default to one for a single panel; set two when the opening is a pair of leaves that meet in the middle. Hinges equal openings times leaves times hinges per leaf. Gate width and the optional hinge threshold must share the same length unit—feet with feet, metres with metres—because the tool never converts units and only needs the dimensionless comparison of leaf width to the threshold.
What you can do with it
Backyard walk-gate hardware list
Homeowners enter one or two openings and each gate width to get posts, hinges, and latches before shopping for strap hinges and latch kits.
FAQ
How are latches counted?
Latches equal the number of gate openings. Each opening gets one latch assembly, whether the opening is a single leaf or a double gate.
What if gate width is zero or negative?
Gate opening width must be strictly positive; zero or negative width cannot define a gate.
Is the fence gate calculator free?
The browser tool is free and runs locally.
How many hinges does a gate need?
Two per leaf when the leaf is up to 5 units wide, in the same unit as the gate width, and three when it is wider, to help against sagging. You can also set your own count from 1 to 10 hinges per leaf.
How do I count hardware for a double gate?
Set two leaves per opening. Each leaf is then half the opening width, which decides its hinge count, while the opening still needs only two posts and one latch assembly, such as a drop rod with a latch kit.
How many posts do fence gates need?
Two per opening: one on the hinge side and one on the latch side. That holds for single and double gates alike, so 2 openings need 4 gate posts. If two gates share a post back to back, subtract it on site.
Related tools
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/home/fence-gate \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"gates":2,"gate_width":4}'const res = await fetch("https://api.kit.forhosting.com/home/fence-gate", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"gates": 2,
"gate_width": 4
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/home/fence-gate",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"gates": 2,
"gate_width": 4
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/home/fence-gate", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"gates":2,"gate_width":4}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"gates":2,"gate_width":4}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/home/fence-gate", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"gates": 2,
"gate_width": 4
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "home.fence_gate",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |
Technical notes
Wide leaves automatically pick three hinges when you leave hinges_per_leaf blank; narrow leaves stay on two, and you can override either choice. Zero or negative gate width is rejected with invalid_input instead of inventing hardware, and non-positive gate counts fail the same way.
How gate posts, hinges, and latches are counted from openings and width
When you omit hinges_per_leaf, the calculator measures leaf width as gate_width divided by leaves_per_gate and applies a simple yard rule: two hinges if the leaf is at most the hinge width threshold (default five in whatever length unit you used for width), three hinges if the leaf is wider. That rule mirrors common residential practice where heavier or taller wide leaves get a third hinge for sag control; it is not a structural engineering certificate and you can always force an explicit hinges_per_leaf from one through ten. Latches equal the number of openings: one latch assembly per opening covers a single-gate thumb latch or a double-gate drop-rod-and-latch kit at the shopping-list level. Total opening width is openings times gate_width so you can cross-check how much fence run the gates replace. On success the response echoes rounded inputs, publishes gate_posts, hinges, latches, leaf_width, hinges_auto, formula, message, and steps so you can audit the arithmetic by hand or pin it in automated tests.
How to call the API and what comes back
String forms of whole numbers and decimals are accepted when they match a strict finite numeric pattern; fractional gate or leaf counts are rejected. Prefer sending numbers rather than pre-formatted strings when you control the client; when you must send strings, avoid unit suffixes or thousand separators that would fail the finite-number pattern. Send a JSON body with two required fields: gates (aliases gate_count, num_gates, n_gates, openings) as a positive integer from one through one thousand, and gate_width (aliases width, opening_width, gate_w, W) as a finite positive number within the published absolute range. Optionally send leaves_per_gate (aliases leaves, panels, leaf_count) as one or two—default one when omitted; hinges_per_leaf (aliases hinges_each, hinges_per_panel) as a positive integer up to ten; and hinge_width_threshold (aliases wide_gate_threshold, hinge_threshold) as a positive number in the same unit as gate_width—default five when omitted and only used for auto hinge selection. On success the response sets gate_posts to gates times two, hinges to the product of gates, leaves_per_gate, and hinges_per_leaf, latches to gates, total_opening_width to gates times gate_width, leaf_width to gate_width divided by leaves, hinges_auto true when hinges were chosen from the threshold rule, formula to the posts hinges latches expressions, message to a short English summary, and steps to an ordered substitution log. Failed validation—missing fields, non-finite numbers, zero or negative width, non-positive gate counts, leaves outside one or two, hinges outside one through ten, or values outside absolute limits—returns invalid_input and is never charged. Pricing is a flat $0.002 per successful request with unit item.
Practical tips, limits, and related searches
Keep gate counts inside one through one thousand and dimensions inside the published absolute range so counts remain safe integers. Call once per distinct opening size if widths differ, then sum posts, hinges, and latches across calls. Round-trip checks are easy: recompute two posts per gate, multiply leaves and hinges per leaf, set latches equal to gates, and confirm the published integers match. Measure the clear opening between finished posts or between the planned post faces, not the panel blank before trim, so gate_width matches what you will hang. For a four-foot walk gate use leaves_per_gate one and leave hinges auto or set two; for a ten-foot driveway double gate use leaves_per_gate two so each five-foot leaf is evaluated for the third hinge when the default threshold is five. If your region always uses three hinges regardless of width, set hinges_per_leaf explicitly and ignore the threshold. When teaching or writing tests, pair a narrow single gate that auto-selects two hinges with a wide leaf that auto-selects three, add an explicit hinges_per_leaf override, and include a deliberate zero or negative gate_width to prove the invalid_input path. This landing targets people searching for a fence gate calculator, how many hinges for a gate, gate posts and latches material list, or double gate hardware counts online; it is not a fence post spacing tool for the long runs between openings, not a picket or board counter, not a concrete post-hole volume estimator, and not a wind-load or code compliance engine. Prefer home.fence_posts when you already know run length and post spacing for the solid fence segments, and prefer this capability when the question is only gate hardware. Failed tasks that return invalid_input do not consume prepaid balance, which keeps exploratory scripts cheap when you deliberately send bad widths to verify error handling.
Integration use cases
Driveway double-gate take-off
Builders set leaves_per_gate to two, feed opening width, and attach gate_posts, hinges, latches, and steps to a transparent quote.
Golden fixtures for construction apps
Developers generate known-good auto-hinge and explicit-hinge cases plus deliberate zero-width rejections for unit tests and CI.
Technical questions
How many posts do I need for fence gates?
For independent openings, gate_posts = gates × 2 (one hinge post and one latch post per opening). Example: 2 gates → 4 gate posts.
How many hinges does a fence gate need?
Hinges = gates × leaves_per_gate × hinges_per_leaf. If you omit hinges_per_leaf, the tool uses 2 when leaf width is at most the threshold (default 5), otherwise 3.