Bounding box contains check
An outer box from (0, 0) to (10, 10) fully contains an inner box from (2, 3) to (5, 7): all four edges nest. Enter both boxes' edges and see which side, if any, breaks containment. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Outer min x
- 0
- Outer max x
- 10
- Outer min y
- 0
- Outer max y
- 10
- Inner min x
- 2
- Inner max x
- 5
- Outer width
- 10
- Outer height
- 10
- Inner width
- 3
- Inner height
- 4
Axis-aligned bounding box containment is a fundamental spatial predicate used in mapping, computer graphics, collision broad-phases, GIS tile hierarchies, and viewport culling. Given two rectangles whose sides are parallel to the coordinate axes, the question is whether the outer box completely encloses the inner one—not merely whether they overlap or share a corner. This bounding box contains check accepts eight finite edge bounds (minimum and maximum X and Y for the outer container and the inner candidate), validates that each box has min less than or equal to max on both axes, and then evaluates four closed inequalities: the outer left edge must sit at or left of the inner left edge, the outer right at or right of the inner right, and the same nesting on the bottom and top. Equal boxes count as containment under closed edges.
What AABB containment means and how the four edges are tested
An axis-aligned bounding box, often abbreviated AABB, is defined by a minimum and maximum coordinate on each axis. Full containment of an inner box by an outer box means every point of the inner rectangle also belongs to the outer rectangle. Because both shapes are products of intervals, that set inclusion reduces to interval nesting on each axis independently: the inner X-interval must lie inside the outer X-interval, and the inner Y-interval must lie inside the outer Y-interval.
If any one of those four checks fails, the outer box does not fully contain the inner box—even when the boxes still intersect in a partial overlap or share a boundary only on one side. Degenerate zero-width or zero-height boxes are allowed when min equals max; a point-like box is contained when that point lies on or inside the outer edges. Two identical boxes also satisfy containment, because every edge is equal and the closed inequalities remain true.
This capability does not model rotated rectangles, geodesic spherical polygons, or antimeridian wrapping; it is the classic Cartesian AABB predicate used as a fast broad-phase filter before more expensive geometric tests.
What you enter, what you get and invalid boxes
An inverted box where min is strictly greater than max is rejected rather than silently swapped, because swapping would change the intended geometry without the caller's knowledge. The summary field contains is true only when all four edge flags are true. The equal flag is true when the two boxes share identical edges.
A short message describes full containment, identical boxes, or lists the failing edges when nesting does not hold. Example: outer box from (0,0) to (10,10) and inner box from (2,3) to (5,7) yields contains true with all four edge flags true. Partial overlap or a box that sticks out on one side yields contains false and names the failing side.
Validation failures are not billed.
Where a bounding box contains check earns its keep
Map and tile servers use AABB containment to decide whether a feature bbox is fully inside a viewport, a parent tile, or a geofence rectangle before loading higher-resolution geometry. Game engines and physics engines run the same four-edge test as a cheap broad-phase filter before triangle-level collision. GIS pipelines compare annotation boxes to region extents when clipping exports or validating that a drawn region sits entirely within a licensed map sheet.
Computer-vision and document-layout tools nest detection boxes inside page or crop rectangles to filter false positives that spill outside the frame. Failed validation does not consume balance.
What you can do with it
Viewport and tile nesting
Check whether a feature or child-tile bounding box sits fully inside a map viewport or parent tile before loading detailed geometry.
Broad-phase collision and culling
Filter candidate pairs in games and physics by testing whether one AABB fully contains another before expensive narrow-phase tests.
Layout and detection box validation
Verify that OCR, UI, or object-detection boxes remain entirely inside a page, crop, or licensed region extent.
FAQ
Do identical boxes count as containment?
Yes. Closed edges mean outer min/max may equal inner min/max. The equal flag is true and contains is true when both boxes share the same bounds.
What if min is greater than max on a box?
Inverted boxes are not auto-swapped; fix the edges so min is less than or equal to max on each axis.
Does this handle rotated or geographic antimeridian boxes?
No. This is a Cartesian axis-aligned test only. Rotate shapes into axis-aligned form first, or use a geodesic capability for spherical polygons that wrap the antimeridian.
Is overlapping the same as being contained?
No. Two boxes can overlap or share a border and still fail the test. Containment needs every point of the inner box inside the outer one, so all four edges must nest; one failing edge is enough to return false.
How can I tell which side breaks the containment?
Each edge is checked on its own: left, right, bottom and top. The result marks which of the four passed, and the message names the failing edges, so you can see whether the inner box sticks out on one side or several.
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/geo/bbox-contains-bbox \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"outer_min_x":0,"outer_max_x":10,"outer_min_y":0,"outer_max_y":10,"inner_min_x":2,"inner_max_x":5,"inner_min_y":3,"inner_max_y":7}'const res = await fetch("https://api.kit.forhosting.com/geo/bbox-contains-bbox", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"outer_min_x": 0,
"outer_max_x": 10,
"outer_min_y": 0,
"outer_max_y": 10,
"inner_min_x": 2,
"inner_max_x": 5,
"inner_min_y": 3,
"inner_max_y": 7
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/geo/bbox-contains-bbox",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"outer_min_x": 0,
"outer_max_x": 10,
"outer_min_y": 0,
"outer_max_y": 10,
"inner_min_x": 2,
"inner_max_x": 5,
"inner_min_y": 3,
"inner_max_y": 7
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/geo/bbox-contains-bbox", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"outer_min_x":0,"outer_max_x":10,"outer_min_y":0,"outer_max_y":10,"inner_min_x":2,"inner_max_x":5,"inner_min_y":3,"inner_max_y":7}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"outer_min_x":0,"outer_max_x":10,"outer_min_y":0,"outer_max_y":10,"inner_min_x":2,"inner_max_x":5,"inner_min_y":3,"inner_max_y":7}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/geo/bbox-contains-bbox", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"outer_min_x": 0,
"outer_max_x": 10,
"outer_min_y": 0,
"outer_max_y": 10,
"inner_min_x": 2,
"inner_max_x": 5,
"inner_min_y": 3,
"inner_max_y": 7
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "geo.bbox_contains_bbox",
"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
The result is a boolean contains flag together with per-edge diagnostics so you can see exactly which bound failed when nesting does not hold. The same pure logic powers the free browser tool and the billed API path, so map pipelines and homework checkers never disagree on a nesting decision.
What AABB containment means and how the four edges are tested
In two dimensions that is four numbers: min_x, max_x, min_y, and max_y. Written as inequalities with closed edges, containment holds if and only if outer_min_x is less than or equal to inner_min_x, outer_max_x is greater than or equal to inner_max_x, outer_min_y is less than or equal to inner_min_y, and outer_max_y is greater than or equal to inner_max_y.
Input contract, response shape, and invalid bounding boxes
POST a JSON body with eight required finite numbers: outer_min_x, outer_max_x, outer_min_y, and outer_max_y for the container box, plus inner_min_x, inner_max_x, inner_min_y, and inner_max_y for the candidate box. Each field may arrive as a JSON number or as a numeric string; missing fields, empty strings, and non-finite values fail with invalid_input naming the field. Additionally, each box must be well-formed: outer_min_x must be less than or equal to outer_max_x, and the same min-versus-max rule applies to the outer Y edges and both axes of the inner box. On success the response echoes the eight rounded edge values, reports outer_width, outer_height, inner_width, and inner_height, and returns boolean flags left_ok, right_ok, bottom_ok, and top_ok for each edge test.
Where a bounding box contains check earns its keep
Keep requests small, pin the boolean and edge flags in tests, and you get reproducible nesting decisions for map workers, game servers, and grading scripts without standing up a full spatial database for a simple rectangle test.
Technical questions
How do I check if one bounding box contains another?
Send eight finite edges: outer_min_x, outer_max_x, outer_min_y, outer_max_y, and the same four for the inner box. The API returns contains true when the outer box nests the inner box on all four edges.
What does the bounding box contains check cost?
The browser tool is free. API requests use prepaid KIT balance at $0.002 per successful call; invalid input is not billed.