The definitive guide to turning a 3D model (STL) into printable G-Code โ covering slicer software, settings, CAM workflows, and verification. Updated May 2026.
Quick Answer: To convert STL to G-Code for 3D printing, import the STL into a slicer (Cura, PrusaSlicer, or Bambu Studio), configure layer height, infill, and temperature settings, then click Slice. The slicer outputs a .gcode file. For CNC machining, use CAM software (Fusion 360, Mastercam) instead.
STL (Standard Triangle Language, or stereolithography) is the most universal 3D model format. It describes the surface geometry of a 3D object as a mesh of triangles. STL files contain no color, material, or unit information โ just the geometric shell of the object. They are the standard export format from virtually every CAD program (SolidWorks, Fusion 360, Blender, Tinkercad, FreeCAD) for use in manufacturing.
G-Code (RS-274) is the machine control language that tells a 3D printer or CNC machine exactly where to move, how fast, and what to do at each point. A G-Code file for a 3D print contains thousands to millions of lines describing every layer, every travel move, every temperature change, and every extrusion amount. G-Code is generated from the STL by software โ you never write it manually for a full print.
For FDM 3D printing, slicer software converts STL to G-Code. The slicer slices the model into horizontal layers and generates the toolpath for each layer.
In your CAD software, export as STL. Ensure the mesh is watertight โ no holes, no non-manifold edges, no inverted normals. Use the STL repair tool in Meshmixer, Netfabb, or PrusaSlicer's built-in fixer if needed. A bad mesh produces artifacts in slicing.
| Slicer | Best For | Cost |
|---|---|---|
| Ultimaker Cura | Universal, beginner-friendly, huge plugin library | Free |
| PrusaSlicer | Advanced features, multi-material, Prusa printers | Free |
| Bambu Studio | Bambu Lab printers, fast workflow | Free |
| IdeaMaker | Raise3D printers, industrial workflows | Free |
| Simplify3D | Advanced manual control, complex multi-extruder | $199 |
Click the Slice button. The slicer calculates all toolpaths. Review the layer preview in the slicer. Export the .gcode file to SD card, USB, or send via OctoPrint to your printer.
Before printing, drop the .gcode file into GCodex to inspect the full 3D toolpath. Check layer count, support structure paths, and any unexpected travel moves. This step takes 2 minutes and can save a failed 12-hour print.
Verify your G-Code in the browser โ free, instant, no upload.
Open GCodex Viewer โFor CNC machining, you use CAM (Computer-Aided Manufacturing) software instead of a slicer. CAM software defines cutting toolpaths for subtractive manufacturing โ removing material from a solid block.
In CAM, you import the STL (or preferably a STEP file for better feature recognition), define your cutting tools, stock material size, feeds and speeds, and toolpath strategy. The CAM software generates G-Code post-processed for your specific machine controller (Fanuc, Haas, Siemens, GRBL).