What is a G-code file?
A G-code file is a list of machine instructions that a slicer writes for one specific 3D printer: where to move, how fast, how much plastic to extrude and what temperatures to use. It is the file the printer actually runs, not a 3D model.
| File extension | .gcode, .gco, .g |
|---|---|
| Type | Machine instructions (tool paths) |
| Developed by | MIT (numerical control), standardised as EIA RS-274 |
| First released | 1950s; RS-274-D 1980 |
| Encoding | ASCII text (Prusa .bgcode is a binary variant) |
| Colour / materials | Only as tool-change commands |
| Units | Millimetres (G21) or inches (G20) |
| Exact CAD geometry | — |
| MIME type | — |
| Opens in 3dfiles | Yes – G-code viewer |
About the G-code format
G-code comes from the numerical-control machines of the 1950s and is still the language of CNC mills and FDM 3D printers. A slicer turns an STL or 3MF into thousands of short moves for a given printer, nozzle, filament and settings, so a G-code file made for one printer should not be sent to another.
You can preview a G-code file to check layers, travel moves and print time, but you cannot reliably turn it back into the original model – it only contains the paths of the nozzle.
What a G-code file looks like inside
G-code
M140 S60 ; bed to 60 °C
M104 S215 ; nozzle to 215 °C
G28 ; home all axes
G21 ; millimetres
G90 ; absolute positions
M83 ; relative extrusion
G1 Z0.2 F3000 ; first layer height
G1 X50 Y50 E0.8 F1500 ; move while extruding 0.8 mm of filamentG0/G1 are moves (with E for extrusion and F for speed in mm/min), M104/M109 set the nozzle temperature, M140/M190 the bed. Comments start with ;.
How to open a G-code file
- Preview it layer by layer in the G-code viewer.
- Desktop: the slicer that made it (PrusaSlicer, Bambu Studio, OrcaSlicer, Cura) has a G-code preview.
Common problems
Can I convert G-code to STL?
Not faithfully – the file only holds nozzle paths. Ask for the STL, 3MF or STEP the print was sliced from.
Printer rejects the file
It was sliced for a different printer or firmware (Marlin, Klipper, Bambu). Re-slice the model for your printer.
Questions about G-code files
What is a .bgcode file?
Prusa's binary G-code (2023): the same commands, compressed, with embedded thumbnails and metadata. It is only for Prusa printers and firmware.