{"id":154,"date":"2026-10-18T21:10:23","date_gmt":"2026-10-18T21:10:23","guid":{"rendered":"https:\/\/refracttools.com\/blog\/?p=154"},"modified":"2026-10-18T21:10:23","modified_gmt":"2026-10-18T21:10:23","slug":"svg-path-commands","status":"publish","type":"post","link":"https:\/\/refracttools.com\/blog\/css-techniques\/svg-path-commands\/","title":{"rendered":"SVG path commands explained: M, L, C, Q, A and Z"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">An SVG path is a list of drawing commands in its <code>d<\/code> attribute. <code>M<\/code> moves the pen, <code>L<\/code> draws a straight line, <code>H<\/code> and <code>V<\/code> draw horizontal and vertical lines, <code>C<\/code> and <code>S<\/code> draw cubic B\u00e9zier curves, <code>Q<\/code> and <code>T<\/code> draw quadratic curves, <code>A<\/code> draws an elliptical arc and <code>Z<\/code> closes the shape. Uppercase letters use absolute coordinates; lowercase letters are relative to the previous point. The <a href=\"https:\/\/refracttools.com\/svg-path-editor\/\">SVG path editor<\/a> shows every point and handle of a path so you can see how it is built and drag it into shape.<\/p>\n\n\n\n<div class=\"wp-block-group is-style-refract-takeaways is-layout-constrained wp-block-group-is-layout-constrained\">\n<h3 class=\"wp-block-heading\">Key takeaways<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Every path starts with <code>M<\/code> (move to).<\/li>\n\n\n<li>Uppercase = absolute coordinates, lowercase = relative to the current point.<\/li>\n\n\n<li>Cubic curves (<code>C<\/code>) have two control handles; quadratic curves (<code>Q<\/code>) have one.<\/li>\n\n\n<li>Arcs (<code>A<\/code>) take seven values, two of which are 0\/1 flags that choose which of four possible arcs to draw.<\/li>\n<\/ul>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\">What does each SVG path command do?<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><div class=\"table-scroll\" tabindex=\"0\" role=\"region\" aria-label=\"Scrollable table\"><table><thead><tr><th>Command<\/th><th>Name<\/th><th>Parameters<\/th><th>Draws<\/th><\/tr><\/thead><tbody><tr><td><code>M<\/code> \/ <code>m<\/code><\/td><td>Move to<\/td><td>x y<\/td><td>Lifts the pen and moves it, without drawing<\/td><\/tr><tr><td><code>L<\/code> \/ <code>l<\/code><\/td><td>Line to<\/td><td>x y<\/td><td>A straight line<\/td><\/tr><tr><td><code>H<\/code> \/ <code>h<\/code><\/td><td>Horizontal line<\/td><td>x<\/td><td>A horizontal line<\/td><\/tr><tr><td><code>V<\/code> \/ <code>v<\/code><\/td><td>Vertical line<\/td><td>y<\/td><td>A vertical line<\/td><\/tr><tr><td><code>C<\/code> \/ <code>c<\/code><\/td><td>Cubic B\u00e9zier<\/td><td>x1 y1 x2 y2 x y<\/td><td>A curve with two control points<\/td><\/tr><tr><td><code>S<\/code> \/ <code>s<\/code><\/td><td>Smooth cubic<\/td><td>x2 y2 x y<\/td><td>A cubic curve whose first handle mirrors the previous one<\/td><\/tr><tr><td><code>Q<\/code> \/ <code>q<\/code><\/td><td>Quadratic B\u00e9zier<\/td><td>x1 y1 x y<\/td><td>A curve with one control point<\/td><\/tr><tr><td><code>T<\/code> \/ <code>t<\/code><\/td><td>Smooth quadratic<\/td><td>x y<\/td><td>A quadratic curve with a mirrored control point<\/td><\/tr><tr><td><code>A<\/code> \/ <code>a<\/code><\/td><td>Arc<\/td><td>rx ry rotation large-arc sweep x y<\/td><td>Part of an ellipse<\/td><\/tr><tr><td><code>Z<\/code> \/ <code>z<\/code><\/td><td>Close path<\/td><td>none<\/td><td>A straight line back to the start of the subpath<\/td><\/tr><\/tbody><\/table><\/div><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Absolute or relative coordinates?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><code>L 50 20<\/code> draws a line to the point (50, 20) on the canvas. <code>l 50 20<\/code> draws a line 50 units right and 20 units down from wherever the pen is now. Both describe the same kinds of shape; relative commands are usually shorter because the numbers are smaller, which is why optimisers like SVGO often convert to them. Absolute commands are easier to read and edit by hand.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!-- The same square, two ways --&gt;\n&lt;path d=\"M 10 10 L 90 10 L 90 90 L 10 90 Z\" \/&gt;\n&lt;path d=\"M10 10h80v80H10z\" \/&gt;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The second version also shows how compact path data gets: commands can drop spaces where a letter or minus sign separates the numbers, and a command letter can be left out when it repeats.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How do B\u00e9zier curves work?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A B\u00e9zier curve starts at the current point and ends at its final x y pair. The control points in between don&#8217;t sit on the curve; they pull it towards themselves, like magnets. In design apps these are the handles you drag.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!-- A cubic curve: start (10,80), handles (40,10) and (65,10), end (95,80) --&gt;\n&lt;path d=\"M 10 80 C 40 10, 65 10, 95 80\" \/&gt;\n\n&lt;!-- Continue smoothly: S mirrors the last handle automatically --&gt;\n&lt;path d=\"M 10 80 C 40 10, 65 10, 95 80 S 150 150, 180 80\" \/&gt;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Quadratic curves (<code>Q<\/code>) have one shared handle, so they are simpler but less flexible. Most icons and logos exported from Figma or Illustrator use cubic curves, because that is what the pen tool creates.<\/p>\n\n\n<aside class=\"tool-card tool-card--inline\"><span class=\"swatch\" style=\"background:linear-gradient(135deg,#2f4bff,#ff6fb1)\" aria-hidden=\"true\"><\/span><div class=\"tool-card__body\"><p class=\"tool-card__eyebrow\">Free tool<\/p><p class=\"tool-card__name\">SVG path visualiser &amp; editor<\/p><p class=\"tool-card__blurb\">See every point and curve handle of an SVG path, and drag to edit.<\/p><\/div><a class=\"btn primary\" href=\"https:\/\/refracttools.com\/svg-path-editor\/\">Try it free <span aria-hidden=\"true\">\u2192<\/span><\/a><\/aside>\n\n\n\n<h2 class=\"wp-block-heading\">How does the arc command work?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Arcs are the command people find hardest. <code>A rx ry rotation large-arc-flag sweep-flag x y<\/code> draws part of an ellipse from the current point to (x, y). Between two points there are usually four ellipse arcs of a given size that could connect them, and the two flags pick one:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>large-arc-flag<\/strong>: <code>1<\/code> takes the long way round (more than 180\u00b0), <code>0<\/code> the short way.<\/li>\n\n\n<li><strong>sweep-flag<\/strong>: <code>1<\/code> draws clockwise, <code>0<\/code> anticlockwise.<\/li>\n\n\n<li><strong>rotation<\/strong> tilts the ellipse, in degrees. For circles it makes no difference.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!-- A semicircle from (10,50) to (90,50), radius 40, over the top --&gt;\n&lt;path d=\"M 10 50 A 40 40 0 0 1 90 50\" \/&gt;<\/code><\/pre>\n\n\n\n<div class=\"wp-block-group is-style-refract-callout is-layout-constrained wp-block-group-is-layout-constrained\">\n<p class=\"wp-block-paragraph\"><strong>Arc radius:<\/strong> If the radius is too small to reach the end point, browsers scale it up automatically until the arc fits, rather than failing. That is useful, but it can make a tweaked arc look unexpectedly round.<\/p>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Why would you edit path data by hand?<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Fix an icon that is slightly off the grid<\/strong>, so it looks crisp at small sizes.<\/li>\n\n\n<li><strong>Find a stray point<\/strong> that makes a corner look lumpy.<\/li>\n\n\n<li><strong>Simplify a shape<\/strong> by removing points a design tool added.<\/li>\n\n\n<li><strong>Prepare a path for animation<\/strong>, for example morphing two shapes, which needs matching numbers of points.<\/li>\n\n\n<li><strong>Understand a logo<\/strong> before rebuilding or animating it.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Reading a long <code>d<\/code> string is almost impossible, which is why a visualiser helps. In the <a href=\"https:\/\/refracttools.com\/svg-path-editor\/\">SVG path editor<\/a>, blue squares are points on the path and pink circles are control handles. Drag either to reshape the path, then copy it back out as absolute or relative commands, or as a complete SVG with a fitted viewBox.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Making path data smaller<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Path data is usually the biggest part of an icon file. Rounding coordinates to one decimal place, using relative commands and removing redundant points can shrink it a lot without visible change. The <a href=\"https:\/\/refracttools.com\/svg-optimiser\/\">SVG optimiser<\/a> does this with SVGO, and our guide to <a href=\"\/blog\/image-optimisation\/optimise-svg-files\/\">optimising SVG files<\/a> explains which settings are safe. If you are starting from a PNG, <a href=\"\/blog\/image-optimisation\/convert-png-to-svg\/\">tracing it to SVG<\/a> creates the paths for you.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>Last checked: October 2026.<\/em><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>Sources: <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/SVG\/Tutorial\/Paths\" rel=\"noopener\" target=\"_blank\">MDN: Paths tutorial<\/a>, <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/SVG\/Attribute\/d\" rel=\"noopener\" target=\"_blank\">MDN: d attribute<\/a>, <a href=\"https:\/\/www.w3.org\/TR\/SVG2\/paths.html\" rel=\"noopener\" target=\"_blank\">W3C SVG 2: Paths<\/a>.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>What every letter in an SVG path&#8217;s d attribute means: move, line, cubic and quadratic curves, arcs and close path, absolute versus relative coordinates, and how the arc flags work.<\/p>\n","protected":false},"author":1,"featured_media":153,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_refract_tool":"svg-path-editor","footnotes":""},"categories":[8],"tags":[30,13],"class_list":["post-154","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-css-techniques","tag-svg","tag-ui-design"],"_links":{"self":[{"href":"https:\/\/refracttools.com\/blog\/wp-json\/wp\/v2\/posts\/154","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/refracttools.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/refracttools.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/refracttools.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/refracttools.com\/blog\/wp-json\/wp\/v2\/comments?post=154"}],"version-history":[{"count":1,"href":"https:\/\/refracttools.com\/blog\/wp-json\/wp\/v2\/posts\/154\/revisions"}],"predecessor-version":[{"id":159,"href":"https:\/\/refracttools.com\/blog\/wp-json\/wp\/v2\/posts\/154\/revisions\/159"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/refracttools.com\/blog\/wp-json\/wp\/v2\/media\/153"}],"wp:attachment":[{"href":"https:\/\/refracttools.com\/blog\/wp-json\/wp\/v2\/media?parent=154"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/refracttools.com\/blog\/wp-json\/wp\/v2\/categories?post=154"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/refracttools.com\/blog\/wp-json\/wp\/v2\/tags?post=154"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}