How to Convert STL to G-Code: What You Need to Know Before You Slice

If you've ever downloaded a 3D model or designed one yourself, you've probably ended up with an STL file — the standard format for describing a 3D object's surface geometry. But your 3D printer can't read an STL directly. It needs G-code: a set of precise, line-by-line instructions telling the printer exactly where to move, how fast, and at what temperature.

Converting STL to G-code is called slicing, and understanding what happens during that process makes a real difference in your print quality.

What Is an STL File?

An STL (stereolithography) file stores a 3D model as a mesh of triangles. It describes the shape of an object — nothing more. It contains no information about how the object should be physically built: no layer height, no print speed, no support structures, no material type.

That's why slicing software exists.

What Is G-Code?

G-code is a numerical control language used by CNC machines and 3D printers alike. For FDM (fused deposition modeling) printers, G-code contains instructions like:

  • Move the print head to X/Y/Z coordinates
  • Extrude this much filament
  • Set the hotend to a specific temperature
  • Fan on or off
  • Retract filament to prevent stringing

Every printer manufacturer may use a slightly different dialect of G-code, which is one reason slicing settings matter so much — and why G-code generated for one printer won't always work correctly on another.

The Slicing Process: What Actually Happens 🔧

When you load an STL into slicing software, the program:

  1. Analyzes the mesh — checks for errors like non-manifold geometry or inverted normals that could cause print failures
  2. Orients and scales the model (if you haven't done this manually)
  3. Generates supports — temporary structures for overhangs the printer can't bridge on its own
  4. Calculates infill — the internal pattern and density that gives the part its strength
  5. Slices into layers — divides the model horizontally at your chosen layer height
  6. Assigns print paths — determines the order the printer traces each layer
  7. Outputs G-code — writes the full instruction file ready for your printer

Each of these steps involves decisions, and those decisions directly affect the finished print.

Common Slicing Software Options

Several slicers are widely used across the 3D printing community. They differ in interface complexity, supported printers, and the depth of control they give you:

SlicerBest Known ForSkill Level
Ultimaker CuraBroad printer support, active communityBeginner–Advanced
PrusaSlicerPrusa printers, strong feature setBeginner–Advanced
Bambu StudioTight integration with Bambu hardwareBeginner–Intermediate
Chitubox / LycheeResin (MSLA/DLP) printersBeginner–Intermediate
SuperSlicerAdvanced tuning, Cura/Prusa hybridIntermediate–Advanced
IdeaMakerRaise3D printers, clean interfaceIntermediate

Most of these are free. The right one depends on your printer's ecosystem and how much manual control you want.

Key Settings That Shape Your G-Code

The same STL can produce very different G-code depending on your slicer settings. The most impactful ones:

Layer height — thinner layers (e.g., 0.1mm) produce finer detail but take longer; thicker layers (e.g., 0.3mm) print faster with less resolution.

Infill density and pattern — ranges from 0% (hollow) to 100% (solid). Patterns like gyroid or honeycomb affect strength-to-weight differently than grid or lines.

Print speed — faster speeds reduce print time but can introduce artifacts, stringing, or adhesion failures depending on your material and machine.

Support structures — essential for overhangs beyond roughly 45–50 degrees, but they add print time and require removal afterward.

Wall count (perimeters) — more walls mean a stronger, more solid exterior. Critical for functional parts.

Material profile — temperatures, cooling fan behavior, and retraction settings all vary significantly between PLA, PETG, ABS, TPU, and other filaments.

How to Do the Conversion: A General Workflow

  1. Install a slicer compatible with your printer
  2. Import your STL file — most slicers accept drag-and-drop
  3. Select your printer profile — many slicers include pre-configured profiles for popular machines
  4. Orient the model on the build plate — consider which face benefits from being flat, and where overhangs land
  5. Configure your settings — layer height, infill, supports, material temp
  6. Preview the slice — almost all modern slicers show a layer-by-layer preview before export; use it
  7. Export as G-code — save to SD card, USB, or send directly via network depending on your printer

Some printers (particularly those from Bambu Lab and a few others) use compressed or proprietary variants of G-code, so always verify what format your specific machine expects.

Resin vs. FDM: Different Printers, Different G-Code 🖨️

If you're using a resin printer (MSLA or DLP), the process is similar in concept but different in execution. Resin slicers generate exposure times per layer rather than extrusion paths. Chitubox and Lychee Slicer are the dominant tools here, and they typically output formats like .ctb or .photon rather than standard G-code.

FDM and resin G-code are not interchangeable — the print technologies are fundamentally different.

Where Your Specific Situation Comes In

The workflow above is consistent across most setups, but what makes a slice good depends entirely on variables specific to you: the printer you're using, the material in your extruder, the purpose of the part (decorative vs. functional), your tolerance for print time vs. quality, and how much post-processing you're willing to do.

A slicer profile tuned for a Prusa MK4 printing PLA won't produce the same results on an Ender 3 printing PETG — even from the same STL. Dialing in those settings for your particular combination of hardware, material, and intended use is where the real craft of 3D printing lives.