Works on this device
Bezier Path Editor
Place points and control handles with the mouse or the keyboard, or type them in a table. The page writes the path as SVG path data and as CSS path(), and works out its length and the exact box around it. You can paste the path data of an SVG to see and change it.
Your path
Click in the drawing to add a point; press on a point and drag it to move it. With the keyboard: ] and [ choose the next or the previous point, the arrow keys move it (Shift: 10 units, Alt: 0.1), Delete removes an end point, Escape chooses none. End points are squares, control points are circles, the chosen point has a ring.
A number between 0 and 1; 0.5 splits it in the middle of t.
In SVG user units. It is also the viewBox of the downloaded file.
Points and pieces
The path has no points. Click in the drawing or choose Add a point.
| Point | Kind | Control 1 x | Control 1 y | Control 2 x | Control 2 y | End x | End y | Choose or remove |
|---|
The largest distance a point may move, in user units.
Path data, length and bounding box
- Length
- Bounding box
- Box round all control points
- Pieces
| Piece | Kind | Length | Turning points |
|---|
Paste path data
Such as M 10 80 Q 52 10 95 80. Commands M, L, H, V, C, S, Q, T, A and Z. It replaces the path in the drawing; Undo brings the old one back.
How to use the editor
- Choose the kind of the next piece: Line, Quadratic curve (one control point) or Cubic curve (two control points).
- Click in the drawing to add a point at the end of the path. Press on a point and drag it to move it. Moving an end point takes its own control points with it. To move a point without dragging, tick A click moves the chosen point, click the point, then click where it should go.
- With the keyboard: put the focus on the drawing, choose a point with ] and [ (or Page Down and Page Up), move it with the arrow keys (Shift for 10 units, Alt for 0.1), and press Delete to remove an end point. Add a point adds a point after the last one.
- In the table, type exact numbers, change the kind of a piece, close a part, or remove a point. A number typed in the table changes only that number.
- To change a path you already have, paste its d attribute under Paste path data and choose Read path data.
- Copy the path data or the CSS, or choose Download SVG. Undo and Redo step back and forward.
How it is worked out
- A cubic Bézier curve from P0 to P3 with control points P1 and P2 is B(t) = (1 − t)³ P0 + 3 (1 − t)² t P1 + 3 (1 − t) t² P2 + t³ P3 for t from 0 to 1. A quadratic curve is B(t) = (1 − t)² P0 + 2 (1 − t) t Q + t² P2.
- Length: a line is measured exactly. A curve is the integral of its speed |B′(t)| from t = 0 to 1, worked out with 16-point Gauss–Legendre quadrature on 16 equal parts of t (the method of the Motion Path Generator). Where the curve stops for a moment (a cusp, or a point where it turns back on itself) the speed is 0, and the integral is split there first. A closed part adds the straight line back to its start.
- Bounding box: the box round the end points and the points where a curve turns in x or in y. There dx/dt = 0 or dy/dt = 0, which is a linear equation for a quadratic curve and a quadratic equation for a cubic curve, solved in closed form. The control points usually lie outside this box; the control box round all points is shown too.
- Quadratic to cubic is exact: the control points of the cubic are P0 + 2/3 (Q − P0) and P2 + 2/3 (Q − P2).
- Cubic to quadratic is not always possible exactly. One quadratic with Q = (3 P1 − P0 + 3 P2 − P3) ÷ 4 differs from the cubic by at most √3 ÷ 36 × |P3 − 3 P2 + 3 P1 − P0| at the same t. The page splits each cubic curve into as many equal parts of t as needed for your tolerance, and says the largest change.
- Split a piece: the de Casteljau construction gives two pieces of the same kind with exactly the same shape.
- Pasted path data may use M, L, H, V, C, S, Q, T, A and Z. H and V become lines, S and T get their control points, and an arc (A) becomes cubic curves of at most 90° each (SVG 2, appendix B.2.4), which stay within about 0.03% of the radius of the true arc.
Worked example
The example path is M 40 160 C 40 60, 160 60, 160 160 S 280 260, 280 160 Q 320 100, 360 160 L 360 240 L 40 240 Z.
The first cubic curve has its control points at y = 60, but it turns at t = 0.5, where y = 0.125 × 160 + 0.375 × 60 + 0.375 × 60 + 0.125 × 160 = 85. The smooth curve S gets the control point (160, 260), the reflection of (160, 60), and turns at y = 235. The quadratic curve turns at y = 0.25 × 160 + 0.5 × 100 + 0.25 × 160 = 130. So the bounding box runs from x = 40 to 360 and from y = 85 to 240: 320 × 155. The control box is 320 × 200.
The length is 214.6509 + 214.6509 + 103.9714 + 80 + 320 + 80 (the closing line) = 1,013.2732 units. The shortest path data is M40 160c0-100 120-100 120 0s120 100 120 0q40-60 80 0v80H40z.
With a tolerance of 0.5, each cubic curve becomes 3 quadratic curves, and no point moves more than 0.4277 units: |P3 − 3 P2 + 3 P1 − P0| = 240, and √3 ÷ 36 × 240 ÷ 3³ = 0.4277.
Limits you should know
- Up to 2,000 pieces and coordinates from −1,000,000 to 1,000,000. Pasted path data up to 100,000 characters.
- The path data rounds coordinates to the decimals you choose. The length and the box use the unrounded points, and are shown to 4 decimals.
- Arcs are read as cubic curves and written as cubic curves. Browsers may measure a path with their own methods, so their lengths can differ in the last digits.
- One path at a time. To edit a whole SVG file (colours, elements, code), use the SVG Editor & Optimizer. To make a smooth path through points for an animation, use the Motion Path Generator. For a timing curve such as cubic-bezier(0.25, 0.1, 0.25, 1), use the Easing Function Visualizer.