ForHosting KIT · Math

Perimeter of a rectangle

A rectangle 8 long and 5 wide has a perimeter of 26, twice the sum of its sides. Enter the length and the width to get the distance all the way round, ready for trim, fencing or a frame. Free in your browser.

  • Free
  • Runs in your browser
  • No sign-up
  • Your data stays on your device
Use it from WebAPIEmailTelegramApp soon
If you enter
Length
8
Width
5
You get
Perimeter
26

The perimeter of a rectangle is the total distance around its four sides. Students, drafters, fence estimators, picture framers, and grading scripts ask for this number constantly from two measurements already sitting on a plan or a homework line. Zero is a degenerate strip whose go-and-return path is still well-defined; a missing or non-finite value is not.

What the formula means and why two sides suffice

A rectangle is a four-sided plane figure with four right angles and opposite sides equal. Walking once around the figure you travel the length, then the width, then the length again, then the width again, so the closed path is two lengths plus two widths. Factoring that walk produces the school identity this capability evaluates: P equals two times (length plus width).

You do not need the area, the diagonal, an aspect ratio, or an interior angle. Two finite side lengths determine the boundary completely. Searchers looking for the perimeter of a rectangle typically already have those two numbers—a measured wall and the adjacent wall, a homework item that states length eight and width five, a picture frame whose opening is known in both directions—and they want the boundary length, not a general polygon toolkit and not the sibling calculator that recovers a missing side from a given area.

Units stay consistent: if length and width are metres, the perimeter comes back in metres; if they are inches, you get inches of path. A square is the special case in which length equals width, which yields P equals four times that common side, the familiar square perimeter. Zero is allowed as a degenerate rectangle whose path is twice the remaining side.

What to enter and what you get back

A negative length or a negative width also fails, because a geometric edge cannot be negative—there is no meaningful perimeter for an inverted figure, and inventing an absolute value would hide a data-entry mistake. On success the body echoes length and width, returns perimeter as two times their sum, rounds every numeric field to twelve decimal places for stable goldens across runtimes, and includes a formula string restating P equals two times (L plus W).

Example: length eight and width five yield perimeter twenty-six, because two times (eight plus five) is twenty-six. A square check is length seven and width seven, which yields perimeter twenty-eight. A thin-strip check is length four and width zero, which yields perimeter eight.

Where a length-and-width rectangle perimeter calculator earns its keep

Interior design, fencing, and framing work often know both wall lengths from a tape measure or a plan; the perimeter sets baseboard, skirting, drip-edge, picture-rail, or fence-run quantities without converting through area. Packaging and print shops that store both cut-edge dimensions recover the cut-path length for trim, foil, or gasket in one call. Game and CAD tools that already store length and width convert to perimeter for collision padding, path-length animations, or material estimates.

Construction worksheets that list form-board length and width recover the remaining run of edging. Keep requests small, pin the rounded perimeter in tests, and you get reproducible boundary lengths for homework, LMS plugins, CAD macros, and edge workers without standing up a general polygon library when the only figure that matters is a rectangle whose two sides are already known. Prefer this focused solver over the area-and-one-side sibling when the search intent is specifically P equals two times (L plus W) from both sides.

Fencing, framing, and trim from two measured sides

Two wall lengths from a tape or a drawing become a perimeter for skirting, drip-edge, picture-rail, or fence-run quantities without going through area.

Packaging cut-path and CAD macros

Scripts that already store both cut-edge dimensions recover the cut-path length for trim, foil, gasket, or collision padding under one deterministic contract.

How do I find the perimeter of a rectangle from its length and width?

Send two finite non-negative numbers: length L and width W. Example: length 8 and width 5 give perimeter 26.

What happens if length or width is negative?

A geometric edge cannot be negative; failed validation is not billed.

Can I use it for a square?

Yes. Enter the same value for the length and the width, and the result is four times that side. A square is simply the special case of a rectangle whose two sides are equal.

Is a width of zero allowed?

Yes. A zero width describes a flat strip, and the perimeter is then twice the length, so 4 and 0 give 8. Negative sides are refused, because an edge cannot have a negative length.

Which unit does the perimeter come out in?

In the same unit as the sides. Enter metres and you get metres, enter inches and you get inches; the calculator does not convert, so measure both sides in one unit.

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.

POSThttps://api.kit.forhosting.com/math/perimeter-of-rectangle

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.

curl -X POST https://api.kit.forhosting.com/math/perimeter-of-rectangle \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"length":8,"width":5}'
{
  "length": 8,
  "width": 5
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "math.perimeter_of_rectangle",
  "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.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

When both the length and the width are known, that distance is given by the closed identity P equals two times the sum of the two sides: P = 2(L + W). This calculator accepts those two finite numbers, rejects a negative length or a negative width with invalid_input, and returns the perimeter together with a short formula string you can show next to the answer.

What the formula means and why two sides suffice

Negative sides are rejected rather than silently producing an inverted figure: a geometric edge cannot have a negative measure, and the capability encodes that impossibility as invalid_input so clients that treat empty success and hard failure differently for billing and retries stay honest.

Input contract, response shape, and validation rules

POST a JSON body with two required fields: length, the finite non-negative length of one pair of opposite sides, and width, the finite non-negative length of the other pair. The length may also arrive under the aliases l, L, or a; the width may arrive as w, W, or b so client code can match textbook notation. Each value may be a JSON number or a numeric string; empty strings, missing fields, non-numeric text, NaN, and Infinity fail with invalid_input naming the field. Failed validation does not consume prepaid balance. Pair the response with your own unit conversion or drawing code if needed—this endpoint derives the perimeter only and does not emit area, diagonals, angles, or plots.

Classroom and homework checks

Let students submit length and width for a rectangle and verify the perimeter P = 2(L + W) against the textbook walk around the four sides.

Is a square allowed?

Yes. When length equals width the formula reduces to P = 4L, the familiar square perimeter. Send the same number for both fields.

Is this the same as finding the perimeter from area and one side?

No. That search asks for P = 2(s + A/s) when only the area and one edge are known. This calculator assumes both sides are already known and returns P = 2(L + W).

What does the rectangle perimeter calculator cost?

The browser tool is free. API requests use prepaid KIT balance at $0.002 per successful call; invalid input is not billed.

Read the full KIT documentation →