G-code vs SVG for CNC Routers: How Files Become Tool Paths
SVG is geometry; G-code is movement. CAM software converts SVG to G-code by choosing tool diameter, speed, feed rate, and Z-depth. G-code runs on the router. Understanding this gap prevents crashed bits and ruined parts.
November 25, 2026 · 10 min read
G-code vs SVG on a CNC router is not a format rivalry — the two describe fundamentally different things. SVG is geometry: an XML document of paths, arcs, and shapes that says what the design is. G-code is motion: a text program of coordinates, feed rates, and spindle commands that says what the machine should do, in what order, with which tool. No router executes SVG. Between them sits CAM software, which converts vector paths into toolpaths by applying decisions SVG cannot express — tool diameter, cut depth, feed and speed, climb versus conventional, pass order — and then posts G-code the controller runs. Understanding that gap is what separates clean parts from crashed bits and ruined stock.
G-code vs SVG: What Each Format Stores
An SVG file holds resolution-independent geometry: <path> elements with Bézier control points plus visual styling (stroke, fill, color). It has no tools, no speeds, no Z axis, and no material. Its dimensions live in user units that may or may not map to millimeters. A G-code file, by contrast, is a numbered instruction list for one specific machine and one specific tool. G0 X10 Y20 rapids to a coordinate; G1 Z-3 F300 feeds down 3 mm at 300 mm/min; G2 and G3 cut clockwise and counterclockwise arcs; M3 S12000 starts the spindle at 12,000 RPM; M5 stops it; M2 ends the program. A simple 100 mm pocket in MDF can generate 2,000–8,000 G-code lines — 100–400 KB — from an SVG source of 5 KB. The explosion happens because CAM replaces every curve with the controller's motion primitives, offset by a specific tool radius, across multiple depth passes.
| Concept | SVG | G-code |
|---|---|---|
| Describes | Shape geometry | Machine motion |
| Units | User units, physical units optional | Explicit: G20 (inches) / G21 (mm) |
| Tools | None | Tool numbers, diameters, M6 changes |
| Speeds | None | Feed rate F, spindle speed S |
| Depth | Flat 2D — Z is implied | Every Z move programmed, often multi-pass |
| Portability | Universal across design tools | Dialect-specific per controller |
| Typical size, one part | 2–20 KB | 50–500 KB |
How CAM Software Turns SVG into Toolpaths
The CAM step is where every manufacturing decision gets made. In Carbide Create, Easel, VCarve, or Fusion 360 you import the SVG, then define the tool (for example a 1/8 in two-flute upcut end mill), the material (MDF, hardwood, aluminum), stock thickness and Z zero location, depth per pass (commonly half the tool diameter in wood — about 1.5 mm for a 3 mm bit), feed rate (600–1,500 mm/min in hardwood on a hobby router; 3,000+ mm/min on industrial machines), spindle speed (10,000–24,000 RPM for small bits), and cutting strategy (profile, pocket, V-carve, raster engrave). The software then offsets each path by the tool radius, sequences cuts so pockets clear before profiles release the part, adds lead-in moves, replaces vertical plunges with ramps or helices, and posts the result to a controller-specific dialect.
Why can't a CNC router read SVG directly?
Because SVG contains no manufacturing decisions. A path says a circle is 50 mm across, but not which bit cuts it, how deep, how fast, in how many passes, or in which direction around the material. Controller firmware — GRBL, LinuxCNC, Mach3, Fanuc — understands only motion primitives: rapids, linear feeds, arcs, spindle on/off. CAM software is the translator that applies tool geometry, feeds, speeds, and pass order, then emits G-code. A few browser-based senders translate SVG on the fly for laser-style GRBL boards, but the translation always happens somewhere.
G-code Dialects: GRBL, LinuxCNC, Mach3, and Fanuc
G-code is a family of dialects, not one language. Core motion codes (G0/G1/G2/G3, G20/G21, G90/G91, M3/M5/M6) are near-universal; almost everything else varies: arc plane handling, canned cycles like G81 drilling, tool-change behavior, comment syntax (semicolons versus parentheses), line numbering, and decimal parsing. GRBL — the firmware inside most hobby routers such as Shapeoko, X-Carve, and 3018 machines — implements a deliberately compact subset: no automatic tool changer, few canned cycles, arcs restricted to the XY plane, and a 128-character serial line buffer. LinuxCNC and Mach3 accept richer dialects, and industrial Fanuc or Haas mills add macro programming on top. Post processors exist precisely for this reason: the CAM tool's GRBL post emits only what GRBL understands. Posting with the wrong dialect produces mysterious alarms — GRBL error 15 means a move exceeds machine travel — or silently skipped moves that ruin the part.
Is G-code the same on every CNC machine?
No — G-code is a family of dialects. Basic motion commands are portable, but tool changes, canned cycles, comments, arc planes, and error handling differ between GRBL, Mach3, LinuxCNC, and Fanuc-style industrial controls. A file posted for one controller can alarm or skip moves on another. Always post from CAM using the dialect that matches your controller, and dry-run new posts with the spindle off and stock cleared before cutting real material.
Toolpath Types a CNC Router Actually Uses
- Profile / contour: cuts the outline. The tool centerline rides offset outside the path for final part dimensions and inside for holes — a 6 mm bit on a 100 mm square path yields a 106 mm part or a 94 mm pocket depending on side.
- Pocket: clears an enclosed region in a spiral or zig-zag raster, typically in multiple Z passes of 1–3 mm each in wood.
- V-carve / engrave: a V bit follows vectors with depth varying by path width — the classic sign-making pass, where a 90° bit cuts wider as it deepens.
- Raster / 3D relief: dense scanline passes over a heightfield, tens of thousands of short G1 moves, used for carved artwork and molds.
- Drilling: peck or standard cycles at point locations — G81/G83 on full controllers, simple plunge-retract loops on GRBL.
What feed rate and depth of cut should I start with?
Start conservative and test in scrap: for a 1/8 in (3.175 mm) two-flute upcut in MDF on a hobby router, run 10,000–15,000 RPM, 800–1,200 mm/min feed, and 1.5 mm depth per pass. Hardwoods take about half that feed rate. The underlying math is chip load: feed equals RPM times flutes times chip load, with 0.1–0.25 mm per tooth typical for small bits in wood. Too slow rubs and burns the material; too fast deflects or snaps the bit.
Common Conversion Failures Between SVG and G-code
Scale errors. SVG user units default to 96 per inch; a design intended at 100 mm can import at 96 mm, 25.4 mm, or 104 mm depending on unit metadata and the CAM importer's assumptions. Measure the imported bounding box before toolpathing anything. Open paths. Profile cuts need closed contours; a 0.2 mm gap flips the operation to a pocket or throws an error. Close paths in the vector editor first. Duplicate geometry. Two coincident lines cut twice — wasted time, a weakened edge, and visible burn marks on laser-style heads. Live text. CAM tools have no font engine; convert lettering to outlines before export. Node bloat. Auto-traced artwork with 20,000 nodes posts enormous G-code full of microscopic moves that stall GRBL's motion planner; simplify paths to a 0.1–0.3 mm tolerance before CAM.
Our SVG to G-code converter handles the geometry-to-motion mapping for standard 2.5D profiles and engraving passes, image to G-code generates raster depth relief from grayscale sources, and DXF to G-code takes CAD exports through the same pipeline. For bitmap logos, vectorize cleanly first — the image tracing guide explains how node counts and thresholds decide whether your toolpaths stay smooth.
Which File Should You Hand a CNC Router?
Never SVG or DXF directly — always G-code posted for your specific controller, generated by CAM from clean vector geometry. The division of labor: SVG and DXF are design and exchange formats that travel between people and programs; G-code is machine-specific output that should be regenerated for each machine, tool, and material. Keep the vector master archived, treat G-code as a disposable build artifact, and re-post rather than hand-edit coordinates. That workflow — design in vectors, decide in CAM, execute in G-code — is the foundation of reliable CNC practice, and it is why a 5 KB drawing can become a 300 KB program that the router reads one motion at a time.
Frequently asked questions
Can I send an SVG file directly to a CNC router?
No. Router controllers — GRBL, Mach3, LinuxCNC, Fanuc — execute G-code motion commands, and SVG contains no motion, tool, speed, or depth information. CAM software must translate the geometry first: it offsets paths by tool radius, sets feeds and speeds, sequences passes, and posts G-code. A few browser senders translate simple SVG on the fly for lasers, but routers with Z axes and tool changes always need a CAM step.
What is the difference between G-code and SVG?
SVG describes what a shape is; G-code describes what a machine does. SVG stores resolution-independent geometry — paths, arcs, styling — in about 2–20 KB. G-code stores coordinates, feed rates, spindle speeds, and depth moves for one specific tool and controller, typically 50–500 KB per part, because every curve becomes a series of motion commands repeated across multiple depth passes.
What software converts SVG to G-code?
CAM software does the conversion: Carbide Create and Easel (free, hobby-focused), Vectric VCarve and Aspire (sign-making standard), Fusion 360's integrated CAM (free for personal use), EstlCAM, and open-source FlatCAM. Each imports SVG or DXF, lets you assign tools, depths, feeds, and strategies, then posts G-code in your controller's dialect. Simple 2D profiles can also come from lightweight browser-based SVG-to-G-code converters.
Which G-code dialect does my CNC router need?
Check the controller, not the router brand. Hobby machines (Shapeoko, X-Carve, 3018, most Chinese routers) typically run GRBL, which supports a compact subset: G0/G1 motion, XY-plane arcs, no tool changer, 128-character lines. Industrial mills run Fanuc, Haas, or Heidenhain dialects with canned cycles and macros; Mach3 and LinuxCNC accept richer variants on retrofits. Post with the matching profile in your CAM software — wrong dialects cause alarms or silently skipped moves.
Why is my G-code file so much larger than the SVG?
Because CAM replaces compact geometry with explicit motion. One smooth SVG curve becomes dozens of G1/G2 commands, offset by tool radius and repeated at every depth pass — a 5 KB design can post 2,000–8,000 lines, 100–400 KB. Raster engraving and 3D reliefs are worse: dense scanline toolpaths run to megabytes of tiny coordinate moves. The size is normal; controllers stream G-code line by line rather than loading it all into memory.
Sources
Convert files for this workflow
Try it on your own file
Drop in an image or an SVG and see the result before you pay. No signup is required to preview.