What STL to G-Code conversion does, and why you need it
An STL file is a 3D model — it describes the shape of an object as a solid form in space. A G-code file is a set of instructions that tells a 3D printer exactly where to move, how fast to move, when to heat up, and when to extrude plastic or resin. Converting STL to G-code means taking that shape and turning it into a step-by-step recipe your printer can follow.
Your 3D printer cannot read an STL file directly. It needs G-code. The conversion happens in software called a slicer, which cuts your 3D model into thin horizontal layers, figures out how to fill each layer, and writes out every movement the printer's nozzle or laser needs to make.
The slicer also lets you choose settings that change how the print turns out: layer height, infill density, print speed, nozzle temperature, and support structures. These choices matter more than the STL itself — the same model can print well or poorly depending on the settings you pick.
Key Takeaways
- You convert STL to G-code using slicing software, not a simple file converter — the software must know what printer model you own.
- Common free slicers are Cura (for most FDM printers), PrusaSlicer (especially for Prusa printers), and SuperSlicer (a community fork with more options).
- The slicer needs your printer's profile, which includes nozzle size, build plate dimensions, and heating capabilities — this comes built in for popular printers.
- Settings like layer height, infill, and support type have the biggest effect on print quality and time, and you can adjust them before converting.
- After slicing, you save the G-code file and transfer it to your printer via USB, SD card, or network, depending on your printer model.
Choosing a slicer that matches your printer type
The first step is picking a slicer. Your choice depends on what kind of printer you own. FDM printers (the most common type, which melt plastic filament) use different slicers than resin printers, and some slicers work better with certain printer brands.
For FDM printers, Cura (made by Ultimaker, free and open-source) works with hundreds of printer models and is the easiest entry point. PrusaSlicer (free, made by Prusa) is built for Prusa printers but also supports many others. SuperSlicer is a community-maintained fork of PrusaSlicer with more advanced options — use it if you want finer control over settings.
For resin printers, the slicer is often made by the printer manufacturer. Formlabs printers use PreForm, Anycubic printers often use Photon Workshop, and Elegoo printers use ChituBox. Check your printer's manual or the manufacturer's website to find the correct slicer.
Download the slicer from the official website, not a third-party site. Install it on your computer (Windows, Mac, or Linux depending on the slicer). When you open it for the first time, you will see a setup wizard asking you to choose your printer model — select the exact model you own, because the slicer needs to know your build plate size and nozzle type.
Loading your STL file and choosing print settings
Open your slicer and import your STL file using File > Open or by dragging the file into the window. The model will appear on a virtual build plate. You can rotate it, move it, or scale it to fit your printer's build area.
Before slicing, you need to choose settings. The most important ones are:
- Layer height: How thick each layer is, measured in millimeters. Smaller layers (0.1 mm) give smoother surfaces but take longer. Larger layers (0.3 mm) print faster but look rougher. Start with 0.2 mm as a middle ground.
- Infill: How solid the inside of the print is, as a percentage. 20% infill is light and fast; 100% is solid but uses more plastic and time. Most prints use 15–20%.
- Support type: Whether the slicer adds temporary structures to hold up overhanging parts. Tree supports use less material than linear supports but take longer to remove. Choose based on your model's geometry.
- Print speed: How fast the nozzle moves, in millimeters per second. Faster (60–100 mm/s) saves time but risks quality. Slower (30–50 mm/s) improves detail. Start with the slicer's default.
- Nozzle and bed temperature: These depend on your filament type. PLA typically prints at 200°C nozzle and 60°C bed; PETG at 230°C and 80°C. Check your filament's packaging.
Most slicers come with preset profiles for common materials. Click the profile dropdown and select the filament type you are using — the slicer will set temperature and speed automatically. You can then tweak individual settings if needed.
Running the slice and checking the preview
Once your settings are chosen, click the Slice button (or Prepare to Print, depending on the slicer). The software will process your model, which takes anywhere from a few seconds to a few minutes depending on model complexity and your computer's speed.
After slicing, the slicer shows you a preview of each layer. Use the slider to scroll through the layers and look for problems: gaps where the nozzle will miss, thin walls that might break, or supports that look unstable. If something looks wrong, go back and adjust settings — for example, if walls are too thin, lower the print speed or increase nozzle temperature to help plastic flow better.
The slicer also estimates print time and plastic weight. These estimates are usually within 10–15% of reality. If the time is much longer than you expected, you can increase layer height or lower infill to speed it up.
Saving the G-code file
When the preview looks good, save the G-code file. Click File > Export or Export G-code. Choose where to save it on your computer — most people create a folder called "G-code" or "Prints" to keep them organized.
The filename does not matter for printing, but naming it after the model and settings (like "Benchy_0.2mm_20infill.gcode") makes it easy to find later. Some slicers let you add notes to the file, which is useful if you are testing different settings on the same model.
The file size is usually between 1 and 50 megabytes, depending on model complexity and layer height. This is normal and does not affect print quality.
Transferring G-code to your printer
How you get the G-code onto your printer depends on your printer model. Most printers use one of three methods:
- USB cable: Plug your printer into your computer with a USB cable. The slicer may have a "Print" button that sends the file directly. If not, copy the G-code file to the printer's storage as if it were a USB drive.
- SD card: Insert an SD card into your computer, copy the G-code file to it, eject the card, and insert it into your printer. Use the printer's menu to select and start the print.
- Network: Some printers (especially Prusa and higher-end models) connect to your WiFi. The slicer can send files over the network directly, or you can upload them through the printer's web interface.
Check your printer's manual to see which method it supports. If you are using an SD card, format it as FAT32 before copying files — most SD cards come pre-formatted this way, but older cards may need reformatting.
Troubleshooting common conversion problems
If your slicer will not open your STL file, the file may be corrupted or have geometry errors. Try opening it in a repair tool like Netfabb (free online version at netfabb.autodesk.com) or Meshmixer. These tools can fix small holes or flipped normals that prevent slicing.
If the preview shows gaps or missing sections, your model may have internal geometry or floating parts. Rotate the model in the slicer to see all sides. If parts are truly disconnected, you may need to edit the STL in a 3D modeling tool like Fusion 360 or Blender before slicing again.
If the slicer crashes or freezes, try lowering the layer height or simplifying the model. Very complex models with millions of triangles can overwhelm older computers. You can also try a different slicer — sometimes one slicer handles a problem file better than another.
If the G-code file is huge (over 100 MB), your printer may not have enough storage. Lower the layer height or increase it to reduce file size, or split the model into multiple prints.
Frequently Asked Questions
Can I convert STL to G-code without owning a printer?
Yes. You can slice any STL file and save the G-code to test settings or prepare files before you get a printer. The G-code will only work on the printer model you selected in the slicer, so if you later buy a different printer, you will need to re-slice the file with that printer's profile.
What if my printer model is not in the slicer's list?
Check the printer manufacturer's website for a custom profile you can import. If none exists, you can create a manual profile by entering your build plate dimensions, nozzle size, and heating limits. Start with a similar printer's profile as a template. Many online communities share profiles for less common printers.
Do I need to use the slicer the printer manufacturer recommends?
No. Any slicer that has your printer's profile will work. Some people prefer Cura for its simplicity, others use PrusaSlicer for its features. The printer does not care which slicer made the G-code, only that the G-code is correct for its hardware.
Can I edit G-code by hand after slicing?
Technically yes, but not recommended unless you know G-code syntax. Small edits (like changing print speed with an M220 command) are safe, but mistakes can crash your printer or ruin a print. If you need to change settings, re-slice the file instead.
How do I know if my G-code file is correct before printing?
Open it in a G-code viewer like Octoprint's built-in viewer, Repetier-Host, or an online tool like gcode.ws. The viewer shows you a 3D preview of the print path, layer by layer. If it looks wrong, do not print — go back to the slicer and adjust settings.