
STL to G-code: It Is Not a Conversion, It Is Slicing
There is no STL-to-G-code converter, and any site offering one is guessing at your printer. G-code is a list of machine moves, not a shape — here is what actually produces it, and why going back the other way loses the model.
If you came here looking for a converter, the short version is: there isn't one, and there cannot be one. Download a slicer — PrusaSlicer, Cura, Bambu Studio or OrcaSlicer, all free — open your STL, pick your printer, and export. That step is called slicing, and it is the thing you are looking for.
The longer version is worth two minutes, because it explains why every "STL to G-code online" page you find is either a slicer in disguise or a dead end.
Why it cannot be a conversion
A conversion rewrites the same information in a different notation. STL to OBJ is a conversion: both files describe a surface made of triangles, so the triangles come out the other side unchanged.
STL and G-code do not describe the same kind of thing at all.
An STL says what shape something is — here are 40,000 triangles, arranged like this.
G-code says what a machine should do — go to X 110.4 Y 98.2, extrude 0.031 of a millimetre of filament on the way, set the nozzle to 215°C, move up 0.2 mm and do the next layer. It is a script, not a model.
Getting from one to the other needs information that is nowhere in the STL:
- which printer, and how big its bed is
- nozzle diameter and layer height
- what material, and at what temperature
- how fast to move, and how much to retract
- where supports go, what the infill pattern is, how many perimeters
Change any one of those and the same STL produces a completely different G-code file. There is no single correct answer to convert to, which is why this is a decision-making step performed by a program that knows your machine, not a format translation.
That is also why a website cannot do it for you honestly. It does not know what printer is sitting on your desk.
How to actually do it
- Install a slicer. PrusaSlicer, Cura, Bambu Studio and OrcaSlicer are all free, and any of them will do.
- Pick your printer from its list. This matters more than anything else on this page — the bed size, nozzle and firmware flavour all come from here.
- Open the STL. Check the size before you go further; if a model imports at the wrong scale, an STL carries no unit to correct it from (why that happens).
- Set layer height and infill. 0.2 mm layers and 15% infill is a reasonable starting point for almost anything.
- Slice, then export the G-code.
The slicer will also tell you the estimated time and filament use, which is the other thing no converter could have told you.
Going the other way is worse
G-code to STL is the second most searched version of this question, and the
honest answer is that you should avoid needing it.
G-code is a set of paths, not a surface. You can trace the extrusion moves and build a mesh that roughly hugs them, and a few tools will do exactly that — but what you get back is a model of the print, not of the original object:
- the curves are gone, replaced by the stepped layers that were sliced
- internal geometry is gone; you get infill lattice where solid material was
- dimensions carry the slicer's compensation, not the designer's intent
- a 20-minute print becomes a mesh with millions of triangles
It is a rubbing of a printed part, not the part. If you still have the STL or the STEP, use that. If the original was a CAD file, converting the STEP to STL keeps the exact geometry and is a real conversion.
What you can do with a G-code file in a browser
Reading it is genuinely useful, and it needs no install.
Open the file in a text editor first. Slicers write a header and a settings block as comments, so the first and last few dozen lines tell you which slicer made it, for which printer, at what layer height. If someone sent you a G-code file and you are not sure it matches your machine, that is where you check — before you waste filament finding out.
Then look at the toolpath. Our G-code viewer draws the extrusion and travel moves as line segments, layer by layer, so you can step through and see what the printer is actually going to do: where the supports are, whether the first layer covers what you expected, where the travel moves cross the part. It reads Marlin, Klipper, PrusaSlicer, Cura and Bambu Studio output, and nothing is uploaded — the file is parsed in your own browser.
The commands worth recognising when you skim it:
| Command | What it does |
|---|---|
G0 / G1 | Move to X Y Z, at feedrate F, extruding E |
G28 | Home the axes |
G92 | Reset the position counter |
M104/M109 | Set nozzle temperature (M109 waits) |
M140/M190 | Set bed temperature (M190 waits) |
; | Comment — where slicers hide the settings |
So, to summarise
STL to G-code: use a slicer. It is not a conversion, and the choice of printer is the whole point.
G-code to STL: keep your original file instead. What you can recover is the shape of the print, not the model.
Checking a G-code file: read the comment header for the settings, and view the toolpath to see the layers.

