How to convert an STL file to G-code
This is the walkthrough. If you want to know what G-code is and which slicer suits you, read the longer page on STL to G-code first. If you already have a slicer, or are happy to take a recommendation, this takes about twelve minutes.
This cannot be done in a browser, here or anywhere else. G-code is written for one specific machine, and a file made without knowing your printer can crash the nozzle into the bed. Every step below happens in free software on your own computer.
From STL to a printable file
Written for PrusaSlicer, because it is the clearest of the four for someone doing this the first time. Cura, OrcaSlicer and Bambu Studio follow the same sequence with different menu wording, and the differences are noted where they matter.
Install a slicer
prusa3d.com/prusaslicer → Download → run the installer
It is free and there is no account. Cura is at ultimaker.com/software, OrcaSlicer on GitHub, Bambu Studio at bambulab.com. Any of the four works; pick one and stay with it.
On the first run it asks which mode to use. Choose Expert. Simple mode hides the settings you will want within a week, and finding them again later is harder than seeing them now.
Add your printer
Configuration Wizard → Printer → pick your model → Next
The wizard runs automatically the first time. Find your machine in the list and the bed size, nozzle diameter, speeds and start-up sequence all come with it. This is the step that decides whether everything afterwards works.
If your printer is not listed, look for a profile published by its manufacturer or by its community and import it with File, Import, Import Config. Building one by hand is possible but it is not a first-day job.
Check the nozzle and filament settings
Printer Settings → Extruder 1 → Nozzle diameter
The nozzle diameter here must match the nozzle physically fitted to your printer, which is 0.4 mm unless you changed it. Then pick your filament from the dropdown at the top of the window — PLA, PETG or ABS — so the temperatures match what is on the spool.
A profile set to 0.4 mm with a 0.6 mm nozzle fitted produces over-extruded, blobby prints, and the cause is not obvious from looking at them.
Load your STL
File → Import → Import STL (or drag the file onto the window)
The model appears on a drawing of your print bed. If it is enormous, microscopic, or standing on its side, fix that now rather than later — the size shown is the size it will print.
An STL records no units, so a model that arrives at the wrong scale is normal rather than broken. Right-click it and use Scale to percentage, or scale to a known dimension you can measure on the real object.
Place and orient the model
Right-click the model → Place on face
Pick the flattest face and put it on the bed. This does more for print quality than any slicer setting: it decides how much support you need, where the layer lines show, and which direction the part is weakest in.
A printed part splits along layer lines far more easily than across them. If the part will be loaded in one direction, orient it so that load runs across the layers rather than trying to pull them apart.
Set the four settings that matter
Print Settings → Layers and perimeters / Infill / Support material
Layer height 0.2 mm to start. Perimeters 2 for decorative, 3 for functional. Infill 10 to 15% for decorative, 25 to 40% for functional. Supports off unless something overhangs by more than about 45 degrees from vertical.
Everything else in these menus has a sensible default. Change one thing at a time and print something small to see what it did — that is how you learn what the settings mean, and it is faster than reading about them.
Slice it
Slice now (bottom right)
It takes a few seconds. The estimated time and filament use appear at the bottom right, and if either looks absurd — twenty hours for a small part, or four minutes for a large one — something in the setup is wrong.
Check the preview before you trust it
Preview tab → drag the vertical layer slider
This is the step everyone skips and should not. Drag the slider from bottom to top and watch the print build. You are looking for the first layer covering the area it should, supports where you expected them and nowhere else, and no layer printing into empty space.
Two minutes here catches most of the failures that would otherwise be discovered six hours into a print.
Export the G-code
Export G-code (bottom right) → save to your SD card or USB stick
Save it straight to the card your printer reads. Some printers want the file in the root folder rather than in a subfolder, and some are fussy about long filenames.
If your printer refuses the file, try renaming the extension — .gcode, .gco and .g are the same format and some firmware only accepts one of them.
The same steps in Cura, in Cura’s words
Cura is the slicer most tutorials assume, so it is worth having the wording. Add your printer with Settings, Printer, Add Printer. Load the model with File, Open File, or by dragging it in. Orientation is on the left toolbar: the rotate tool has a Lay flat button that does what Place on face does in PrusaSlicer.
The settings live in the panel at the top right. Click the word Custom to get past the five preset sliders to the real settings. Layer height is under Quality, infill and wall count under their own headings, supports under Support. The Slice button is at the bottom right, the preview is the tab at the top, and Save to Disk writes the file.
One Cura-specific thing worth knowing: the search box at the top of the settings panel works well and is usually faster than hunting through the categories, because Cura organises settings alphabetically rather than by process.
If your model came from somewhere other than an STL
Slicers read STL, 3MF and OBJ directly, and most read STEP now as well. If you have something else — a GLB from a web viewer, an FBX from a game, a COLLADA file from SketchUp — converting it to STL or 3MF first is the missing step, and that part does run in a browser.
Prefer 3MF if your slicer takes it, which all four of these do. It records its units, so the model cannot arrive at the wrong scale, and it keeps separate objects apart instead of merging them into one body.
One thing to check after converting anything that came from the web or from a game: whether the model is actually solid. Models built to be looked at are often hollow shells with holes where the camera never went, and a slicer given one of those does something unpredictable. The converters here report the open-edge count, which is the number that tells you.
What to do when the first print fails
Almost all first-print failures are the first layer, and almost all first-layer failures are the gap between the nozzle and the bed. It should be close enough that the plastic is visibly squashed into a flat line rather than laid down as a round noodle. Most printers have a live Z adjustment you can change while the first layer prints, which is the fastest way to find the right value.
The second most common cause is a dirty bed. Skin oil is grease and grease stops plastic sticking. Isopropyl alcohol on a cloth, every few prints.
If the first layer is fine and the print fails higher up, the cause is different and usually mechanical: a loose belt, a partially blocked nozzle, filament tangled on the spool, or a part that curled up and was knocked off. The longer STL to G-code page lists the common failures and what each one points at.
Where we can actually help
If your model is not an STL yet, that conversion does run here, in your browser, with nothing uploaded. Convert it first, then start at step four above. Once you have exported the G-code, you can open it in the G-code viewer here for a second look at every layer before you print.
Questions
- How long does the whole process take the first time?
- About twelve minutes, of which ten are installing the slicer and adding your printer. After that, slicing a model takes under a minute.
- Do I have to pay for any of this?
- No. PrusaSlicer, Cura, OrcaSlicer and Bambu Studio are all free, and none of them requires an account to slice a file.
- My printer is not in the list. What now?
- Look for a profile published by the manufacturer or by the community for your machine and import it with File, Import, Import Config. Almost every printer with any user base has one. Building a profile from scratch is possible but not a first-day job.
- The model is the wrong size when I load it. Is the file broken?
- No, that is normal. An STL records no units, so the slicer assumes millimetres and a model exported in metres or inches arrives at the wrong scale. Scale it in the slicer, or convert to 3MF first, which does record the unit.
- Should I use the preview?
- Yes, every time. Dragging the layer slider from bottom to top takes two minutes and catches most of the failures that would otherwise be found hours into a print.
Where to go next
Related guides
Tools that do part of this here
About these formats
Checked against current software versions on 2026-09-11