ForHosting KIT · Web Scraping & Monitoring

Compute an SVG path bounding box from path data

This SVG path bounding box calculator reads the coordinate commands from a path data string and returns its minimum and maximum x and y values, plus the resulting width and height.

● BetaFree · in your browser
Use it from WebAPIEmailTelegramApp soon

It follows straight segments, Bézier curves, elliptical arcs, relative commands, smooth control points, and closed subpaths. Because curved segments can extend beyond their endpoints and control points do not necessarily lie on the curve, the calculation evaluates the geometric extrema rather than merely collecting the numbers written in the source.

Calculate bounds from path data alone

Paste the value of an SVG path element’s <code>d</code> attribute into the path field. The calculator accepts the standard move, line, horizontal, vertical, cubic Bézier, smooth cubic, quadratic Bézier, smooth quadratic, elliptical arc, and close-path commands, in both uppercase absolute and lowercase relative forms. It returns <code>min_x</code>, <code>min_y</code>, <code>max_x</code>, and <code>max_y</code>, followed by width and height for convenience. These values describe an axis-aligned rectangle in the path’s own coordinate system. They do not apply transforms from parent groups or the path element, and they do not expand the result for stroke width, line caps, joins, markers, filters, or clipping. That distinction makes the output suitable for geometry work: it measures the path centerline exactly as encoded. An empty path is rejected instead of producing a misleading zero-sized box, while a path containing one move point legitimately produces a box whose width and height are both zero.

Why curves require analytic extrema

A reliable SVG bounding box cannot be found by looking only at segment endpoints. A cubic or quadratic Bézier may reach its smallest or largest coordinate between its start and end, and a control point can sit outside the curve without ever being touched. This calculator solves the derivative of each Bézier coordinate and evaluates every root that lies inside the segment. Elliptical arcs need different treatment: SVG arc radii may be automatically scaled, the ellipse may be rotated, and the large-arc and sweep flags choose one of several possible routes. The implementation converts each arc to its center representation, derives the angles where rotated x or y coordinates are extreme, and includes only candidates that fall on the selected sweep. Smooth commands reflect the appropriate previous control point, relative coordinates use the current point, and closing a subpath includes the line back to its start. This approach provides geometric bounds without sampling, so a narrow peak cannot fall between arbitrary sample positions.

Use the result in SVG tooling and layouts

The returned rectangle is useful when building a viewBox, centering imported artwork, normalizing icons, comparing path extents, positioning annotations, or checking whether generated geometry stays inside an expected canvas. To construct a matching viewBox, use <code>min_x min_y width height</code> in that order. If the artwork has a visible stroke, add the padding required by your stroke and join rules after computing the geometric box; transformed artwork should likewise be transformed before or after this calculation with the appropriate matrix-aware procedure. The parser accepts compact SVG number syntax, including comma or whitespace separators, adjacent signed values, decimals, and scientific notation. It rejects unknown commands, incomplete coordinate groups, malformed text, invalid arc flags, and negative arc radii so that automation fails clearly rather than silently returning partial bounds. Results are deterministic and require no network request or external renderer. The same pure calculation supports the browser tool and API, making it practical for interactive inspection and repeatable build pipelines alike.

Generate a fitted viewBox

Turn the returned minimum coordinates, width, and height into a viewBox that tightly frames path geometry.

Normalize an icon collection

Measure paths consistently before translating or scaling icons into a shared coordinate system.

Validate generated SVG geometry

Check that programmatically produced curves and arcs remain inside the intended canvas limits.

Does the box include curves and arcs accurately?

Yes. It evaluates analytic extrema for Bézier curves and rotated elliptical arcs rather than sampling them.

Does it include stroke width?

No. The result covers path geometry only, without stroke, caps, joins, markers, filters, or other paint effects.

Are SVG transforms applied?

No. Coordinates are measured in the path data’s own coordinate system; element and ancestor transforms are outside the input.

What happens when the path is empty?

The request fails with an invalid input error because empty path data has no bounding box.

What does the API request cost?

Each API request costs $0.002. The browser version runs locally for free.

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/web/svg-path-bounding-box

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/web/svg-path-bounding-box \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"path":"M10 20 C30 0 50 40 70 20 L90 60"}'
{
  "path": "M10 20 C30 0 50 40 70 20 L90 60"
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "web.svg_path_bounding_box",
  "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.

timeout_sec30
max_crawl_pages25
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.

Read the full KIT documentation →