Apps Part of Lumina

Bézier Curve Fitter for SVG Paths

Turn jagged traced outlines or freehand polylines into a few smooth Bézier curves.

More options

Try an example: ·

More about this tool

How it works

Paste SVG path data from a tracer, a drawing tablet or a plotter export. The fitter replaces runs of short segments with cubic Bézier curves and straight lines, keeps sharp corners, and proves that the new path stays within your tolerance of the original in both directions. Pixel mode treats the path as pixel steps (as traced by Lumina Vector Lab) and smooths the stairs; freehand mode follows every point. Lumina Vector Lab uses the same engine for curve smoothing.

  • Path data is read with the full SVG grammar; curves and arcs in the input are flattened to within a tenth of the tolerance first. Every sub-path is fitted separately: closed ones as loops, open ones with both end points kept.
  • Corners are vertices whose direction changes by more than the corner angle, measured over a short window (3 × tolerance, 2 units for pixel outlines); they stay sharp and split the path into runs.
  • Each run is fitted with least-squares cubic Béziers (chord-length parameters, Newton reparameterisation, split at the worst point with a shared tangent). Pixel mode first samples the stairs every half unit and filters the samples (twelve [1 2 1] passes) so the fit follows the smooth shape behind the steps.
  • A curve or line is accepted only with a proven two-sided distance bound to the input run: the curve is flattened with a convex-hull error bound, both polylines are sampled every tolerance / 10, and the bound adds both errors and half the sampling step. Runs that cannot be fitted keep their original segments. Rounding to the chosen decimals is reserved inside the tolerance.

The fitted path stays within the tolerance of the input (after any input curves were flattened to a tenth of it). Fitting does not check whether different sub-paths now touch each other; Lumina Vector Lab adds that check for traced artwork. Up to 200,000 characters, 2,000 sub-paths and 20,000 points.

Sources

Part of Lumina

  • Lumina Photo editor & image toolkit

    Bring out what you saw. A free photo studio, right in your browser.

    Open Lumina

Related tools

How to use the Bézier Curve Fitter for SVG Paths

Replace jagged traced outlines and shaky freehand polylines with a few smooth Bézier curves that provably stay within the distance you choose.

What it is for

Traced artwork and pen-tablet strokes usually arrive as long chains of tiny straight segments: pixel tracers produce staircases, drawing apps record a point every few milliseconds. Such paths are heavy, hard to edit and show visible steps when scaled up.

This tool rebuilds the path from cubic Bézier curves and straight lines. Sharp corners stay sharp, open strokes keep their exact start and end points, and the result is checked against the original: every point of the new path lies within your tolerance of the input and every point of the input lies within the tolerance of the new path. Lumina Vector Lab uses the same engine for its curve smoothing, and Threadsmith uses it when it refits shapes after combining them.

It does not redraw your artwork, guess missing parts or merge separate sub-paths. Each sub-path is fitted on its own.

Worked example

The first example is a hand-drawn wave of 41 points, 5 units apart, with a little jitter. With Freehand or polyline, tolerance 1 and corners sharper than 50°:

  • Nodes before 41, Nodes after 10, Fewer nodes 75.6 %.
  • Curves 6, three straight segments, Proven largest distance 0.9644 units.

Lowering the tolerance to 0.3 keeps more detail: 24 nodes, 8 curves, at most 0.272 units away.

The second example is the outline of a pixel disc with a radius of 10 pixels, exactly as Lumina Vector Lab traces it with smoothing off: 44 nodes of horizontal and vertical steps. In Pixel outline mode with tolerance 1 it becomes 2 nodes joined by 2 curves, at most 0.8118 units from the stairs: a circle of that size needs no more. The same input in freehand mode keeps more of the steps (8 nodes, 6 of them straight segments), because freehand mode treats every corner of the staircase as a point the curve has to pass close to.

How to read the result

  • Fitted path data (d) is ready to paste into the d attribute of an SVG <path>. Closed sub-paths end with Z.
  • Proven largest distance is an upper bound, not an estimate: the fitter flattens each curve with a known error, samples both paths densely and adds both error terms. The true distance is usually a little smaller.
  • Nodes before counts the nodes as written in your input; Nodes after counts on-curve nodes of the result. Fewer nodes is the reduction in percent.
  • Runs that kept original segments counts stretches the fitter could not replace within the tolerance; they stay exactly as they were.

Tips and common mistakes

  • Use Pixel outline for paths made of horizontal and vertical unit steps (pixel tracers, Lumina's silhouette tracer). The fitter then follows the smooth shape behind the stairs instead of every corner.
  • Pixel stairs sit up to about 0.7 pixels away from the shape they approximate, so tolerances below roughly 0.6 cannot remove them; 0.75 to 1.25 works well.
  • For freehand strokes, start with a tolerance of about a third of your stroke width. Bigger values give fewer nodes but can flatten small wiggles you wanted.
  • Raise the corner angle if rounded bends are kept as sharp corners; lower it if real corners get rounded.
  • Keep at least two decimals more than your tolerance needs. With 0 decimals, rounding alone can move points by half a unit.
  • Transforms on the <path> element or its groups are not part of the path data. Inputs are limited to 200,000 characters and 20,000 points.

FAQ

Does the fitted path stay inside my original shape?

No. It stays within the tolerance on both sides, so curves can bulge slightly outside a straight edge or cut a corner of a step. If you need a shape that never grows, use a smaller tolerance.

Can two sub-paths touch or cross after fitting?

This tool fits each sub-path on its own and does not check them against each other. Lumina Vector Lab adds that check for traced artwork and puts any smoothed edge that would touch another edge back to exact pixels.

Why are some parts still straight lines?

Lines are kept where the input really is straight within a small margin, and where no curve passed the distance check. Such runs are listed under Runs that kept original segments.

Guide last updated:

For scripts and AI agents

  • JSON API: POST https://luminacurvefit.usefulweb.app/api/v1/calculate (same calculation as this page)
  • Interface description: OpenAPI 3.1 · AI guide: llms.txt
  • MCP server (Streamable HTTP): https://luminacurvefit.usefulweb.app/mcp · tool name lumina_curve_fit
Example request
curl -s -X POST https://luminacurvefit.usefulweb.app/api/v1/calculate \
  -H 'content-type: application/json' \
  -d '{"path":"M0 49.2 L5 58.2 L10 64.8 L15 70.4 L20 74.8 L25 77.7 L30 80.7 L35 79.9 L40 77.3 L45 72.9 L50 67.2 L55 62.2 L60 54.6 L65 46.8 L70 39.1 L75 32.1 L80 28.1 L85 23.6 L90 20.7 L95 19.6 L100 20.4 L105 25 L110 29.2 L115 34.8 L120 41.2 L125 48.2 L130 57.3 L135 63.9 L140 69.7 L145 74.3 L150 77.3 L155 80.6 L160 80.1 L165 77.7 L170 73.6 L175 67.9 L180 63.2 L185 55.6 L190 47.7 L195 40 L200 32.9","mode":"freehand","tolerance":1,"cornerAngle":50,"precision":2}'
Feedback · ideas & bug reports welcome