# Path Boolean Operations (SVG) > Union, intersect, subtract or exclude two SVG paths, or remove the overlaps of one path. Paste two SVG paths (the d attribute) and combine them like a vector editor's Path menu: union, intersection, difference or exclusion. With an empty second path, union removes overlaps and self-intersections. Curves are flattened within your tolerance, combined exactly as polygons and refitted to Bézier curves; the result is checked against both inputs on a grid of test points. Threadsmith uses the same engine for Object → Combine shapes. Part of usefulweb.app (https://usefulweb.app/). Part of [Threadsmith](https://threadsmith.usefulweb.app/) (ownerApp: threadsmith). Results are deterministic calculations from the inputs and the listed assumptions; the API returns exactly what the web page shows. ## Use it - Human interface: https://threadsmithpathboolean.usefulweb.app/ (interactive tool at https://threadsmithpathboolean.usefulweb.app/tool) - JSON API: POST https://threadsmithpathboolean.usefulweb.app/api/v1/calculate with a JSON object of inputs (schema: https://threadsmithpathboolean.usefulweb.app/api/v1/tool) - OpenAPI: https://threadsmithpathboolean.usefulweb.app/openapi.json - MCP (Streamable HTTP): https://threadsmithpathboolean.usefulweb.app/mcp - tool `threadsmith_path_boolean` ## Inputs - pathA (textarea, required): Path A (SVG path data) - pathB (textarea): Path B (SVG path data; empty = remove the overlaps of path A) - op (select): Operation - fillA (select): Fill rule of path A - fillB (select): Fill rule of path B - tolerance (number): Curve tolerance (path units) - refit (boolean): Refit Bézier curves to the result - fitTolerance (number): Refit tolerance (path units) - precision (integer): Decimals in the result ## Method - Both paths are parsed with the full SVG path grammar (arcs become cubic Béziers, about 2.7e-4 × radius off) and every curve is flattened adaptively so that the polygon stays within the curve tolerance. Open sub-paths are closed, as SVG filling does. - Vertices are snapped to a grid of 1e-9 × the drawing size; all segments are split at their crossings, T-junctions and collinear overlaps (sweep over x-sorted bounding boxes), and identical edges are merged with a signed count per path. - For every edge, an axis-parallel ray from its midpoint across all other edges gives the winding numbers of A and B on both sides. With each path's fill rule this decides whether each side is inside the result; edges with the result on one side only are kept, oriented and chained into rings (tightest turn first), and collinear points are removed. The result has winding ±1 inside, so it fills the same with nonzero and evenodd. - Curve refit: runs between corners (turns sharper than 35°) are fitted with least-squares cubic Béziers (chord-length parameters, Newton reparameterisation, split at the worst point). A curve is accepted only when every polygon point lies within the refit tolerance of the curve and 16 samples of the curve lie within it of the polygon; otherwise straight segments stay. - Check: on a 48 × 48 grid over the drawing, every point farther than twice the tolerances from any outline must be inside the re-read result exactly when the operation says so for its position in A and B. ## Limits - The result is within the curve tolerance of the exact Boolean (plus the refit tolerance when curves are refitted) and rounded to the chosen decimals. Strokes, transforms, clip paths and text are not part of path data; convert them to paths first. Up to 200,000 characters per path and 40,000 segments after flattening.