G-Code 3D Printing Commands: Tutorial, List & How to Use Them
5 min
(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
Understanding the Key 3D Printing File Formats
Understanding the various 3D printing file formats is crucial for achieving optimal results. Different file formats serve different purposes, each offering unique advantages depending on the complexity and requirements of the project. This article will introduce and compare the most common 3D printing file types. 1. STL (Standard Tessellation Language) File structure: STL files use triangular meshes to represent the surface of 3D objects. Each triangle is described by its three vertices, which are exp......
CAD to 3D Print: How to Go from Design to Finished Part
When people first hear about going from CAD to 3D print, it sounds almost too simple: design a part, hit print, and you’re done. But anyone who’s actually tried it knows there are a few critical steps hiding in between. The way you export your CAD file, the software you use to prepare it, and how you handle the slicing process can make the difference between a clean, accurate print and something that belongs in the scrap pile. That’s exactly why many engineers and makers turn to JLC3DP and other 3D pr......
G-Code 3D Printing Commands: Tutorial, List & How to Use Them
(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 i......
Slicer Hacks to Improve 3D Prints
(Source: LiveRoom) Ever wondered why your 3D prints aren't turning out as expected, despite having a well-calibrated printer? The secret often lies in the slicing software. Mastering your slicer settings can transform your prints from mediocre to exceptional. Let's delve into some advanced slicer hacks that can elevate your 3D printing game. Why Slicing Is an Important Step Slicing is the translator between your 3D model and your printer. Think of your slicer as the brain of the operation. It takes yo......
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 ......
3D Model AI Generator: How AI is Revolutionizing 3D Design and Printing
3D Model AI Generator is a tool that uses artificial intelligence technology to automatically generate 3D models. Compared with traditional 3D modeling methods, this type of tool can greatly reduce modeling time and reduce the need for professional skills, allowing more people to easily create 3D content. At present, this type of AI generator is widely used in game development, architectural design, industrial manufacturing, AR/VR, and 3D printing. This article will introduce how AI generates 3D model......