Developer and Text Tools

How SVG Path Data Works and How to Edit It by Hand

Understand SVG path commands M, L, H, V, C, S, Q, T, A and Z, absolute versus relative coordinates, and how to clean and shrink path data for icons.

Saizul Amin
Saizul Amin2 Nov 2026 · 4 min read
How SVG Path Data Works and How to Edit It by Hand

How SVG Path Data Works and How to Edit It by Hand

Open almost any SVG icon in a text editor and you will find a path element with a long d attribute full of letters and numbers. That string is a tiny drawing language, and once you know its ten commands you can fix icons, write shapes by hand and shrink files without a design tool. This guide explains the language and shows how to edit it visually with the free SVG path editor.

The pen model

Think of a pen on paper. Every command moves the pen, and most of them draw while moving. The pen always remembers where it is, the current point, and each command starts from there.

  • M x y moves the pen without drawing and starts a new piece of the shape.
  • L x y draws a straight line to x, y.
  • H x and V y draw horizontal and vertical lines and need only one number.
  • Z closes the shape with a line back to the last M.

A square is simply M10 10 H90 V90 H10 Z.

Curves

C x1 y1 x2 y2 x y draws a cubic Bézier curve. The first two points are handles: they pull the curve towards them but the curve does not pass through them. S is the smooth version: its first handle is the mirror of the previous curve's second handle, so the join has no corner. Q and T are the quadratic equivalents with a single handle. In a visual editor the handles appear as small squares with lines to their anchor points, which is far easier than imagining them from numbers.

Arcs

A rx ry rotation large-arc sweep x y draws part of an ellipse from the current point to x, y. The two flags choose between the four possible arcs that connect the points: large or small, clockwise or anticlockwise. Arcs are the hardest command to write by hand, which is why rounded rectangles in icon files often look cryptic.

Uppercase versus lowercase

Uppercase commands use absolute coordinates. Lowercase commands are relative to the current point: l 10 0 means "ten units to the right of where I am". Relative data is often shorter and makes a shape easy to move, because only the first M holds an absolute position. Exported icons frequently mix both forms.

Why path data gets bloated

Design tools export coordinates with many decimals, repeat command letters that SVG allows you to omit, keep lines of zero length and write lines that are really horizontal as full L commands. None of that changes the picture, but on an icon set of several hundred icons it adds up, and it makes paths hard to read.

Cleaning a path

A good clean-up has four steps:

  1. Round values to the precision you need. For a 24-unit icon, two decimals are more than enough.
  2. Convert lines to H and V where one coordinate does not change.
  3. Write each segment absolute or relative, whichever is shorter.
  4. Remove unnecessary points on nearly straight runs with a tolerance-based simplification.

Compare the shape before and after at the size it will be used. If nothing visible changed, keep the shorter version.

Fitting to an icon grid

Icon systems use fixed boxes, such as 16, 24 or 32 units. Scaling a path so that its bounding box fits that grid, and moving it to start at 0, 0, makes icons line up with text and with each other. A viewBox that matches the box finishes the job.

Editing by dragging

Some fixes are easier to see than to calculate: a curve that bulges too much, a point that is one unit off. Dragging the handle while watching the shape is faster than editing numbers, and the command list keeps the exact values visible so you can finish with precise typing.

Limits

Path data is only the geometry. Stroke width, fills, gradients and transforms on parent groups live elsewhere in the SVG, and changing the path does not adjust them. Very small tolerances in simplification keep detail but save little; large ones save more but can flatten intentional curves, so check the result at the real display size.

Completely freeNo cost, no sign-up
Files stay privateEverything runs in your browser
Easy in your languageAvailable in many languages