This website requires JavaScript.
Coupons
Help

G-Code 3D Printing Commands: Tutorial, List & How to Use Them

Blog  /  G-Code 3D Printing Commands: Tutorial, List & How to Use Them

G-Code 3D Printing Commands: Tutorial, List & How to Use Them

Jul 04,2025

G-Code 3D Printing

(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


CommandDescriptionExample
G1Linear move with extrusionG1 X10 Y10 E1.5 F1500
G28Home axesG28
G90Set absolute positioningG90
G92Set current positionG92 E0
M104Set hotend temp (non-blocking)M104 S200
M109Set hotend temp (wait)M109 S200
M106Fan onM106 S128
M107Fan offM107
M84Disable motorsM84



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.