Volume calculator
Pick a cube, box, sphere, cylinder or cone, type its measurements and get the volume: a cube with a side of 2 holds 8 cubic units. The answer comes in cubic units of whatever length you used. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Shape
- Cube
- Side
- 2
- Volume
- 8
Volume is the measure of the three-dimensional space a solid occupies, reported in cubic units of the same length you send. This volume calculator accepts a shape name — cube, rectangular prism, sphere, cylinder, or cone — together with the dimensions that uniquely determine that solid, and returns the closed-form volume. A cube needs one edge length; a rectangular prism, also called a box or cuboid, needs length, width, and height; a sphere needs a radius; a cylinder and a cone each need a radius and a perpendicular height. Zero is a valid degenerate solid and returns a volume of zero.
Which solid you send and which closed form is used
Volume is the amount of three-dimensional space a solid occupies. Unlike surface area, which counts the outer skin in square units, volume fills the interior in cubic units of the same length you send. The identity is that edge cubed, because a cube is a square prism whose three edges are equal.
The identity is the product of those three edges, the volume of a right rectangular box. Send shape equal to sphere together with a radius. The identity is four-thirds pi r cubed, the unique ball enclosed by a sphere of that radius.
Send shape equal to cylinder together with a radius and a perpendicular height. The identity is pi r squared times h, the area of the circular base extruded through the height. Send shape equal to cone together with a radius and a perpendicular height.
The identity is one-third pi r squared times h, one third of the cylinder that shares the same base and height. That is the whole contract: one shape name, the dimensions that define it, and one volume in cubic units of the same length you sent. An unsupported shape name or any negative dimension fails before a formula runs.
If you need only a unit conversion, a tank fill level, a frustum, a pyramid, or a surface area, use a dedicated tool; the search intent here is volume from a shape name and its dimensions, with a clear number or an honest error.
Input contract, required dimensions, and error behaviour
A cube requires side (or edge, or a). A rectangular prism requires length, width, and height (or l, w, and h). A sphere requires radius (or r).
A cylinder and a cone each require radius and height. Every dimension that the chosen shape needs must be finite. Missing shape, an unsupported shape name, or a missing required dimension fail the same way.
Zero is allowed: a flat cube or a cylinder of height zero is a degenerate solid whose volume is zero, not an input error.
On success the body echoes the canonical shape, echoes the validated dimensions that were used, and returns volume together with a short formula string: V equals a cubed for a cube, V equals l w h for a rectangular prism, V equals four-thirds pi r cubed for a sphere, V equals pi r squared h for a cylinder, and V equals one-third pi r squared h for a cone. Unused dimension keys are omitted, never set to null.
Where a multi-shape volume lookup earns its keep
Students meet these five identities in the same unit of solid geometry: a cubed, length times width times height, four-thirds pi r cubed, pi r squared h, and one-third pi r squared h. A single calculator that dispatches on the shape name lets a learner check every item on a mixed worksheet without opening five different pages or mixing the cone factor of one third with the cylinder formula by hand.
Teachers can pre-generate answer keys that refuse a negative edge instead of printing a signed nonsense volume, and exam platforms can mark a mixed volume section with one deterministic oracle. Packaging, shipping, and storage estimates often start from the same five solids: a cubic carton, a rectangular crate, a spherical tank, a drum, or a conical hopper. Knowing that a requested radius is negative is as valuable as the number itself when a downstream packing list would otherwise go to the warehouse.
Remember the contract limits: this tool does not size a frustum, a pyramid, a torus, a pipe, or a tank fill, and it does not convert liters to gallons. If every length is in centimeters, volume is in cubic centimeters.
What you can do with it
Homework and exam volume drills
Check mixed cube, box, sphere, cylinder, and cone items on one page, and verify that a negative dimension is rejected instead of returning a signed nonsense volume.
Packaging, shipping, and storage estimates
Size the interior of a cubic carton, rectangular crate, spherical tank, drum, or conical hopper from the same shape-plus-dimensions contract.
FAQ
Which dimensions does each shape need?
Cube needs a non-negative side (edge length). Rectangular prism needs non-negative length, width, and height. Sphere needs a non-negative radius. Cylinder and cone each need a non-negative radius and a non-negative perpendicular height.
What happens if a dimension is negative or the shape is unknown?
A negative length is not a geometric measure, and an unsupported shape is not computed. Failed validation is not billed.
Does a zero length fail, or does it return volume zero?
Zero is allowed. A cube of side zero, or a cylinder of height zero, is a degenerate solid whose volume is zero. Only a negative dimension is rejected.
What units does the volume come out in?
Cubic units of the same length you typed. Measurements in metres give cubic metres; the calculator does not convert between units, so every measurement should use the same one.
How is the volume of a cone related to a cylinder?
A cone holds one third of the cylinder with the same base and the same height. The cylinder is pi times the radius squared times the height, and the cone takes a third of that.
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/math/volume \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"shape":"cube"}'const res = await fetch("https://api.kit.forhosting.com/math/volume", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"shape": "cube"
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/math/volume",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"shape": "cube"
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/math/volume", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"shape":"cube"}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"shape":"cube"}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/math/volume", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"shape": "cube"
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "math.volume",
"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
Any unsupported shape name or any negative dimension fails with invalid_input and is not billed.
Which solid you send and which closed form is used
This endpoint is a single dispatcher for five classroom solids. Send shape equal to cube together with an edge length in the field side (aliases edge and a). Send shape equal to rectangular_prism (aliases box and cuboid) together with length, width, and height.
Input contract, required dimensions, and error behaviour
POST a JSON body with a required shape field whose canonical values are cube, rectangular_prism, sphere, cylinder, and cone. The form paints those five as a select; the engine also accepts a few aliases such as box, cuboid, ball, right_cylinder, and right_cone after trimming, lowercasing, and folding spaces or hyphens to underscores. Dimensions arrive as JSON numbers or numeric strings. A negative length is not a geometric measure, so those cases fail with invalid_input and name the failing field before any formula runs.
Where a multi-shape volume lookup earns its keep
On this page the work runs entirely in your browser; through the API each successful lookup costs $0.002, failed validation is not charged, and nothing is stored after the response returns. Whether you arrived searching for a volume calculator or for the interior of a cube, box, sphere, cylinder, or cone, the contract is the same: shape plus non-negative dimensions in, one finite volume or a clear invalid_input out.
Integration use cases
Deterministic geometry fixtures
Generate reproducible volumes for unit tests, contest validators, and CI assertions without hand-rolling a³, lwh, (4/3)πr³, πr²h, or (1/3)πr²h.
Technical questions
How do I compute the volume of a cube, box, sphere, cylinder, or cone?
Send shape plus the dimensions that define that solid: side for a cube; length, width, and height for a rectangular prism; radius for a sphere; radius and height for a cylinder or cone. The API returns the volume and the formula that was used.
What does the volume calculator cost?
The browser tool is free. API requests use prepaid KIT balance at $0.002 per successful call; invalid input is not billed.