How to convert STL to G-code
An STL file describes a shape. A 3D printer does not understand shapes — it follows a list of moves: go here, push this much plastic, heat to this temperature. Turning the first into the second is called slicing, and the program that does it is a slicer. Every slicer worth using is free.
Why STL cannot be converted directly
An STL is a surface made of triangles. It has no layers, no temperature, no speed and no idea which printer it will be made on. G-code is the opposite: a long list of machine commands such as G1 X120.4 Y85.2 E0.034 — move here while pushing out 0.034 mm of filament.
Getting from one to the other involves real decisions: how thick each layer is, how many walls, how much infill, where to put supports, how hot to run the nozzle. That is why there is no simple "STL to G-code converter" that works for everyone. The job is done by a slicer, set up for your printer.
Pick a slicer
All of these are free and run on Windows, macOS and Linux:
- Bambu Studio — made for Bambu Lab printers, also supports others.
- PrusaSlicer — made for Prusa printers, with good profiles for many other brands.
- OrcaSlicer — a community fork of Bambu Studio with profiles for a very wide range of printers.
- UltiMaker Cura — long-standing and widely used; several printer makers ship their own version of it.
If your printer came with a slicer, start with that one: its profiles are already tuned for your machine.
Step by step
- Select your printer when the slicer first starts. This sets the bed size, nozzle and start code.
- Choose the filament you have loaded — PLA, PETG, TPU — so temperatures and cooling are right.
- Import the STL by dragging it into the window. Check the size; if it appears tiny or huge, the file was probably exported in inches or metres — scale it, or fix it with the STL resizer.
- Orient it so the largest flat face sits on the bed. Most slicers have a "lay on face" tool.
- Pick a print profile — usually named by layer height, such as 0.20 mm Standard.
- Slice and look at the preview, layer by layer.
- Export G-code to a USB stick or SD card, or send it to the printer over the network.
The settings that matter
Slicers expose hundreds of options, but a handful decide most prints:
- Layer height. 0.2 mm is the standard on a 0.4 mm nozzle. 0.12 – 0.16 mm for fine detail, 0.28 mm for fast drafts.
- Walls (perimeters). Two is the minimum; three or four make parts much stronger — more than extra infill does.
- Infill. 10 – 20 % for display pieces, 30 – 50 % for functional parts. Gyroid and grid are good defaults.
- Supports. Needed for overhangs steeper than about 45° and for bridges that are long. Tree supports are easier to remove.
- Brim. Adds a thin skirt attached to the part to stop corners lifting. Useful for small or tall parts.
Check the G-code
The slicer preview is the best check: step through the layers and look for gaps, missing walls or supports floating in the air. If you received a G-code file from someone else, or want to look at one without installing a slicer, open it in our G-code viewer. To get a printable model back out of a G-code file, try G-code to STL.
When slicing fails
Holes in the preview, missing layers or strange bridges usually mean the STL itself is broken — open edges, flipped faces or overlapping shells. Run it through STL repair and slice again. If the model is too big for your bed, cut it into pieces with the STL splitter; if it holds several loose parts you want to print separately, use Split STL.
If your file is a 3MF rather than an STL, you are in luck — slicers open 3MF directly and keep colours and settings. The STL vs 3MF guide explains the difference.
Frequently asked questions
Can I convert STL to G-code online?
There are online slicers, but G-code has to match your exact printer — bed size, nozzle, firmware and filament. A desktop slicer with your printer's profile gives far more reliable results, and the common ones are free.
Which slicer is best for beginners?
The one made for your printer: Bambu Studio for Bambu Lab, PrusaSlicer for Prusa, Cura or the vendor's own Cura-based slicer for many others. OrcaSlicer supports a very wide range of printers and is a good all-round choice.
Can I convert G-code back to STL?
Partly. G-code only holds toolpaths, so the original model has to be rebuilt from them. Our G-code to STL tool rebuilds the outer shape from the outer walls, which works well for simple parts.
Why is my G-code file so large?
Every curve is written as many short straight moves, layer after layer. Fine layers, high-resolution models and arc-heavy shapes all multiply the line count. Tens of megabytes is normal for a large print.
Is G-code the same for every printer?
No. The basic move commands are shared, but start and end code, temperatures, bed size and firmware features differ. G-code sliced for one printer should not be sent to another without re-slicing.