What is the GCODE file format?
.gcode is a plain-text file that stores machine instructions for 3D printers and CNC equipment, written in G-code - the dominant numerical control language for motion and machine control. G-code gets its name because many of its core commands begin with the letter "G" (e.g., G0 for rapid move, G28 to home all axes).
G-CODE - how does it work?
.gcode files are generated by slicer software from 3D model files such as .stl or .3mf. Each project is separated into layers; the slicer converts each layer into a sequence of commands defining printing speed, temperature, and the movements of every printer axis. A single print layer is described by a series of commands covering X/Y/Z motion and extruder feed (E-axis).
The format is line-oriented: commands carry numeric parameters (G1 X10.5 Y3.2 F3000) with semicolons marking comments. .gcode files should not be edited by users unfamiliar with the language.
G-code is not one unified standard but a family of dialects - Marlin, Klipper, and Smoothieware each add proprietary M-commands. A file sliced for one printer should always be re-sliced rather than sent directly to a different machine.
Security & safety
RISK: LOWG-code files contain no executable code for a PC OS; they cannot run on Windows/macOS/Linux directly. However, a malformed or malicious .gcode file sent to a 3D printer or CNC machine could command dangerous movements, disable thermal runaway protection (M999 misuse), or cause hardware damage. Only run G-code from trusted sources on your printer. Verify thermal safety settings are active in firmware (Marlin THERMAL_RUNAWAY protection).
Format details
in a nutshell- CNC milling/turning G-code - The original use case (RS-274/ISO 6983): controls mills, lathes, routers - same syntax family but incompatible dialect with 3D printer G-code.
Programs that open GCODE files
Technical details
deep spec| Encoding | Plain ASCII text (7-bit); UTF-8 used for comment fields in some slicers |
| File structure | Line-oriented: one command per line; numeric parameters (X/Y/Z/E/F values); semicolons mark comments |
| Command types | G-words (motion), M-words (machine control), T-words (tool selection) |
| Optional line checksum | N<line_number> … *<checksum_byte> syntax (Marlin/RepRap); most slicer-generated files omit it |
| Typical file size | 10 KB - 200 MB (simple object to complex multi-hour print) |
| File signature | None - plain text; files typically open with a slicer comment (; Generated by ...) or a command such as G28 |
| Dialect incompatibility | Marlin, Klipper, Smoothieware, Fanuc, and Haas dialects are NOT cross-compatible; always re-slice for the target machine |
| FDM-specific commands | M104/M109 (hotend temperature), M140/M190 (bed temperature), E-axis (extruder feed) - absent from CNC mill G-code |
| Standard origin | RS-274D / ISO 6983-1 (1960s CNC standard); .gcode extension popularised by RepRap project circa 2007 |
| Bambu Lab variant | .gcode.3mf container (ZIP archive with embedded G-code and slicer metadata) |
| MIME type | text/x.gcode (also text/plain) |
| Related extensions | .nc, .gco, .ngc, .tap - same language family, different naming conventions across CNC vendors |
| Released | 1960s (RS-274 standard); .gcode extension popularized by RepRap project ~2007 |
| Latest version | ISO 6983-1:2009 (CNC); RepRap/Marlin dialects evolve continuously |
| Open standard | Yes · royalty-free |
| Specification | reprap.org |
GCODE conversions
Community Q&A
asked by usersNo questions yet - be the first to ask about GCODE files.