G-Code 3D Printing Commands: Tutorial, List & How to Use Them
5 min
- G-code Command Types: G vs. M
- M-code Essentials
- G-code in Action: Example Walkthrough
- G-code Customization Tips
- Quick Reference Table: Common G-code Commands
- Conclusion
(Freepik)
If you’ve ever peeked insidfe a 3D printer’s sliced file and seen a wall of cryptic letters and numbers, congrats, you’ve met G-code. It’s not flashy. It’s not forgiving. But it’s the language that tells your printer exactly how to bring your model to life, line by line, millimeter by millimeter.
Most users never touch G-code because slicers handle it automatically. However, If you're serious about improving your prints, understanding G-code 3D printing isn't optional, it's essential.
This isn’t a “G-code 101” list ripped from a wiki. This guide is written for actual 3D printing users, those who want to get under the hood. We’ll walk through how G-code works, which commands matter most, and how to apply them with confidence. You’ll get real syntax examples, practical tips, and a curated command list tailored for 3D printing.
G-code Command Types: G vs. M
All G-code commands fall into two categories:
● G-commands (General): Every line of G-code in 3D printing tells your machine what to do, move here, heat that, cool down, repeat.
● M-commands (Miscellaneous): Control everything else, temperatures, fan speeds, motors, and system-level functions.
Understanding this split helps you instantly recognize the purpose of a command line.
Need help dialing in your G-code or printing complex geometries? Our 3D printing service is equipped to handle custom requests, tight tolerances, and fast turnarounds. Online 3D Printing Instant Quote - JLC3DP.
Must-Know G-code Commands for 3D Printing
Here’s a G-code 3D printing list of the most essential commands every maker should know. These are the backbone of any slicing-generated G-code file, and the same ones you’ll tweak when troubleshooting or customizing your printer.
G0 / G1 — Linear Movement
These handle motion on the X, Y, Z axes and extrusion:
G1 X50 Y20 Z0.2 E3 F1500 ; Move to (50,20,0.2), extrude 3mm at 1500mm/min
G0 is usually reserved for rapid non-extruding moves.
G28 — Auto Home
Sends the printer to its endstops to establish reference position:
G28 ; Home all axes
G90 / G91 — Positioning Mode
● G90: Absolute positioning (default)
● G91: Relative positioning
G91 ; All movements from current position
G92 — Set Position
Override current position without moving the print head:
G92 E0 ; Set current extruder position to 0
G29 — Auto Bed Leveling
Triggers a mesh-based or probe-based leveling process, depending on firmware.
M-code Essentials
M104 / M109 — Set Hotend Temperature
● M104: Set temp and continue
● M109: Set temp and wait
M109 S210 ; Heat nozzle to 210°C and wait
M140 / M190 — Set Bed Temperature
Same structure as hotend, but for the bed:
M140 S60 ; Set bed temp to 60°C
M190 S60 ; Wait until it reaches 60°C
M106 / M107 — Fan Control
M106 S255 ; Full fan power
M107 ; Turn fan off
M84 — Disable Motors
Useful at the end of a print:
M84 ; Turn off stepper motors
G-code in Action: Example Walkthrough
Here’s how a typical print session starts:
G90; Absolute positioning
M82; Absolute extrusion
M104 S200; Set nozzle temp
M140 S60; Set bed temp
G28; Home axes
G29; Auto bed leveling
M109 S200; Wait for nozzle
M190 S60; Wait for bed
G1 Z0.2 F1200; Move to start height
These lines prep the machine with just enough logic to ensure reliable first-layer placement.
G-code Customization Tips
Want better print quality or need to debug layer issues? Knowing how to manually modify the start and end G-code sections in your slicer can help you:
● Add priming lines
● Customize cooling fan ramps
● Implement nozzle wiping routines
● Reduce stringing by tweaking retraction sequences
Most slicers like Cura or PrusaSlicer let you modify these in the machine settings.
Want to push your slicer beyond default settings? Check out our Slicer Hacks to Improve 3D Prints to fine-tune your output and unlock pro-level print quality.
Quick Reference Table: Common G-code Commands
| Command | Description | Example |
| G1 | Linear move with extrusion | G1 X10 Y10 E1.5 F1500 |
| G28 | Home axes | G28 |
| G90 | Set absolute positioning | G90 |
| G92 | Set current position | G92 E0 |
| M104 | Set hotend temp (non-blocking) | M104 S200 |
| M109 | Set hotend temp (wait) | M109 S200 |
| M106 | Fan on | M106 S128 |
| M107 | Fan off | M107 |
| M84 | Disable motors | M84 |
Terminal G-code Use: Manual Inputs
Using software like OctoPrint or Pronterface? You can send manual commands directly to your printer. It's perfect for:
● Tuning PID values
● Reporting temperatures (M105)
● Changing acceleration or jerk
● Testing endstop function
This kind of control is key for advanced debugging and firmware configuration.
Firmware Differences & Compatibility Notes
Not all firmware interprets G-code the same way:
● Marlin is widely supported and most slicers are compatible with it.
● Klipper allows higher speeds and more custom macros.
● RepRap supports unique commands like G10/G11 for retraction.
Always check your firmware documentation or slicer post-processing settings before inserting custom G-code manually.
Conclusion
Learning how to write and modify G-code in 3D printing can save you hours of frustration and open up advanced features. While slicers handle the heavy lifting, knowing what’s going on under the hood can take your skills to the next level.
And if you’d rather skip the code entirely and let the pros handle the precision? Request a free quote from our 3D printing experts. We’ll bring your ideas to life.
Keep Learning
How to Open STL Files: 4 Free Ways (Online, Windows, Mac)
Key Takeaways The fastest way to open an STL file is to drag it into a free online 3D viewer — no installation, works on any device with a browser. On Windows, the built-in 3D Viewer app ships with Windows 10 but may be missing on recent Windows 11 builds, and Paint 3D left the Microsoft Store in November 2024 — the built-in route is fading. macOS and phones ship with no STL viewer at all; a browser-based viewer covers both without installing anything. STL files carry no units. Always confirm the file......
OrcaSlicer vs Prusa, Bambu & Cura: All Features, Pros & Cons Compared
Orca Slicer is gaining fans fast, but is it really better than the slicers we’ve trusted for years? Whether you're troubleshooting stringy overhangs, dialing in support settings, or optimizing for speed, your slicer software plays a massive role in how your final print turns out. And with the growing popularity of Orca Slicer, especially among Bambu Lab users and tinkerers looking for more control, the question arises: how does it actually stack up against Cura, PrusaSlicer, and Bambu Studio? In this ......
What Is an STL File? Inside the Format Every Slicer Reads
Key Takeaways An STL file describes a 3D shape as a list of triangles — geometry and nothing else. No units, no color, no material, no assembly structure. The format dates to the late 1980s, created for the first stereolithography machines, and it remains the one format practically every slicer reads. STL comes in binary and ASCII variants holding the same mesh; ASCII runs several times larger and has no place in a print workflow. A fully closed shell of triangles. Holes and flipped normals are the de......
How to Repair STL Files: Fix Mesh Errors Before 3D Printing
Key Takeaways STL file repair fixes mesh errors such as holes, non-manifold edges, flipped normals, and duplicate vertices, but it does not correct incorrect dimensions or underlying geometry. Before you repair an STL file, check its dimensions and units. STL files generally do not store explicit unit information, so incorrect scale can make a printable model unusable. A repaired or fully closed STL file is not necessarily printable. Repair only fixes mesh errors — wall thickness, minimum feature size......
The Best Websites to Get 3D Printing Files in 2026
Looking for free 3D printer files that actually print well? This guide compares the best websites to download STL files, free printable 3D models, engineering CAD files, and commercial-use designs. Whether you need functional parts, prototypes, toys, or production-ready files, these platforms offer different strengths in model quality, licensing, and supported formats. Quick Comparison Table Not all free STL websites are built for the same use cases. Some focus on hobby printing, while others are bett......
Beginner's Guide to Designing Printable 3D Models
Key Takeaways The file is the hard part: A model that looks perfect on screen can fail on the printer if geometry is open, walls are too thin, or units are wrong. Pick the workflow before the software: Functional parts need parametric CAD, organic models need mesh/sculpting, and simple items suit browser-based tools. Printability is a design step: Fix non-manifold geometry, close meshes, merge intersecting bodies, and meet minimum wall thickness before exporting. Export and verify carefully: Choose ST......