Repository navigation
G code Reference
A comprehensive G-code command reference organized by firmware, with color-coded categories for quick visual scanning.
Universal commands supported across most 3D printer firmwares.
| Command | Name | Key Parameters | Description | Example |
|---|---|---|---|---|
G0 |
Rapid Move | X Y Z F |
Fast travel move without extrusion |
G0 X100 Y50 F6000 — travel to X=100 Y=50 at 100mm/s |
G1 |
Linear Move | X Y Z E F |
Controlled move with optional extrusion — the main printing command |
G1 X10 Y20 E0.5 F1200 — extrude 0.5mm of filament while moving to X=10 Y=20 at 20mm/s |
G2 |
Clockwise Arc | X Y I J E F |
Arc move clockwise. I/J = offset to arc center |
G2 X10 Y15 I5 J0 F1000 — CW arc to X=10 Y=15, center offset I=5 J=0 |
G3 |
Counter-Clockwise Arc | X Y I J E F |
Arc move counter-clockwise |
G3 X10 Y15 I5 J0 F1000 — CCW arc, same as G2 but opposite direction |
G4 |
Dwell (Pause) | P S |
Pause for P milliseconds or S seconds without moving |
G4 P2000 — pause for 2 seconds (2000ms) |
G5 |
Bezier Spline | X Y I J P Q E F |
Cubic Bezier curve move for smooth paths |
G5 X20 Y10 I2 J3 P-2 Q5 F1200 — smooth Bezier curve to X=20 Y=10 |
G10 |
Firmware Retract | S |
Retract filament using firmware-configured length/speed |
G10 — retract filament (length set by M207) |
G11 |
Firmware Recover | — | Push filament back after G10 retraction |
G11 — unretract after a G10 retract |
G12 |
Nozzle Clean | P S T |
Run nozzle cleaning pattern (stroke, zig-zag, circular) |
G12 P1 S3 T2 — zig-zag pattern, 3 strokes, 2 triangles |
G17 |
Set XY Plane | — | Select XY plane for arc commands (used before spiral lifts) |
G17 — set XY as the active arc plane |
G20 |
Set Units to Inches | — | Switch coordinate interpretation to inches |
G20 — all subsequent coordinates in inches |
G21 |
Set Units to Millimeters | — | Switch coordinate interpretation to millimeters (default) |
G21 — all subsequent coordinates in mm (default) |
G27 |
Park Toolhead | P |
Move nozzle to predefined park position |
G27 P0 — park at the default position |
G28 |
Home Axes | X Y Z |
Move to home position using endstops. No params = home all |
G28 X Y — home only X and Y axes |
G90 |
Absolute Positioning | — | Coordinates are measured from bed origin (default) |
G90 — positions are now absolute from origin |
G91 |
Relative Positioning | — | Coordinates are distances from current position |
G91 then G1 Z5 — move 5mm up from current Z |
G92 |
Set Position | X Y Z E |
Define current position without moving. G92 E0 resets extruder |
G92 E0 — reset extruder position to zero |
| Command | Name | Key Parameters | Description | Example |
|---|---|---|---|---|
M104 |
Set Hotend Temp | S T |
Start heating nozzle, don't wait. S=temp C, T=extruder index |
M104 S210 — set nozzle to 210C, continue immediately |
M105 |
Report Temperatures | — | Request current temperatures of all heaters |
M105 — prints T:210.0 /210.0 B:60.0 /60.0
|
M109 |
Wait for Hotend Temp | S R T |
Set hotend temp and wait. S=heat only, R=exact temp |
M109 S200 — heat to 200C and wait until reached |
M140 |
Set Bed Temp | S |
Start heating bed, don't wait |
M140 S60 — set bed to 60C, continue immediately |
M141 |
Set Chamber Temp | S |
Set heated chamber temperature, don't wait |
M141 S45 — set chamber to 45C (enclosed printers) |
M190 |
Wait for Bed Temp | S R |
Set bed temp and wait. S=heat only, R=exact |
M190 S60 — heat bed to 60C and wait |
M191 |
Wait for Chamber Temp | S R |
Set chamber temp and wait |
M191 S40 — wait for chamber to reach 40C |
| Command | Name | Key Parameters | Description | Example |
|---|---|---|---|---|
M106 |
Set Fan Speed | S P |
Set part cooling fan speed (0-255). P=fan index |
M106 S255 — part cooling fan at full speed |
M107 |
Fan Off | — | Turn off part cooling fan (same as M106 S0) |
M107 — turn off part fan |
| Command | Name | Key Parameters | Description | Example |
|---|---|---|---|---|
M82 |
Absolute Extrusion | — | E values are total filament since last G92 E0 |
M82 — E values are cumulative totals |
M83 |
Relative Extrusion | — | E values are amount per move (no running total) |
M83 — each E value is per-move distance |
M200 |
Set Filament Diameter | D T |
Set filament diameter for volumetric extrusion |
M200 D1.75 — set 1.75mm filament diameter |
M207 |
Set Retract Length | S F Z |
Configure firmware retraction length, speed, and Z lift |
M207 S0.8 F4500 Z0.2 — 0.8mm retract at 75mm/s, 0.2mm Z hop |
M208 |
Set Recover Length | S F |
Configure firmware retraction recovery length and speed |
M208 S0.0 F3000 — no extra prime, recover at 50mm/s |
M412 |
Filament Runout | S |
Enable/disable filament runout sensor |
M412 S1 — enable runout sensor |
M600 |
Filament Change | X Y Z E L |
Retract, park, wait for filament swap, reload, resume |
M600 — pause, unload filament, wait for user to swap |
M702 |
Unload Filament | T U |
Unload filament from extruder |
M702 T0 — unload filament from extruder 0 |
M900 |
Linear Advance | K |
Set pressure advance K-factor for extrusion compensation |
M900 K0.04 — set linear advance factor to 0.04 |
| Command | Name | Key Parameters | Description | Example |
|---|---|---|---|---|
G29 |
Auto Bed Leveling | — | Probe bed to create compensation mesh. Home (G28) first |
G28 then G29 — home all axes, then probe bed mesh |
G30 |
Single Z-Probe | X Y |
Probe one point, report Z height |
G30 X100 Y100 — probe center of 200mm bed |
G33 |
Delta Auto Calibration | C V |
Calibrate delta geometry (delta printers only) |
G33 V3 — full delta calibration with verbose output |
G34 |
Z Stepper Alignment | I T A |
Align multiple Z steppers by probing near each motor |
G34 I5 T0.02 — iterate up to 5 times, 0.02mm accuracy |
G35 |
Tramming Assistant | S |
Probe bed screws, report how much to turn each knob |
G35 — probe all corners, display adjustment amounts |
G38.2 |
Probe Toward Target | X Y Z F |
Move toward target, stop on probe trigger (error if no trigger) |
G38.2 Z-10 F200 — probe downward 10mm at 200mm/min |
G38.3 |
Probe Toward (No Error) | X Y Z F |
Move toward target, stop on trigger (no error if missed) |
G38.3 Z-5 F100 — gentle probe, no error if nothing found |
M48 |
Probe Repeatability Test | P |
Probe same spot repeatedly, report standard deviation |
M48 P10 — probe 10 times, report deviation |
M420 |
Bed Leveling State | S Z |
Enable/disable bed leveling. Z=fade height |
M420 S1 Z10 — enable leveling, fade out by Z=10mm |
M421 |
Set Mesh Point | I J Z |
Manually set a mesh bed leveling point value |
M421 I2 J3 Z-0.05 — adjust mesh point [2,3] by -0.05mm |
| Command | Name | Key Parameters | Description | Example |
|---|---|---|---|---|
M17 |
Enable Steppers | X Y Z E |
Power on stepper motors (locked in place) |
M17 X Y — lock X and Y motors |
M18 |
Disable Steppers | S |
Power off steppers (alias for M84). S=idle timeout |
M18 S120 — disable after 120s of idle |
M84 |
Disable Steppers | S |
Power off stepper motors (axes can move freely) |
M84 — release all stepper motors immediately |
M92 |
Set Steps Per Unit | X Y Z E |
Calibrate steps/mm for each axis |
M92 E415 — set extruder to 415 steps/mm |
M201 |
Set Max Acceleration | X Y Z E |
Set maximum acceleration per axis |
M201 X1000 Y1000 — max 1000mm/s2 for X and Y |
M203 |
Set Max Feedrate | X Y Z E |
Set maximum speed per axis (mm/s) |
M203 X300 Y300 Z12 — limit speeds per axis |
M204 |
Set Acceleration | P T S R |
P=print, T=travel, S=legacy accel (mm/s2) |
M204 P1500 T3000 — print at 1500, travel at 3000 mm/s2 |
M205 |
Set Jerk/Junction | X Y Z E J |
Set jerk limits or junction deviation |
M205 X10 Y10 — set XY jerk to 10mm/s |
M206 |
Set Home Offset | X Y Z |
Offset the home position for each axis |
M206 Z-0.1 — shift home Z down 0.1mm |
M211 |
Software Endstops | S |
Enable/disable software endstop limits |
M211 S0 — disable endstop limits (caution) |
M220 |
Set Speed Factor | S |
Override print speed as percentage (S100=normal) |
M220 S80 — slow print to 80% speed |
M221 |
Set Flow Factor | S T |
Override extrusion flow as percentage (S100=normal) |
M221 S95 — reduce flow to 95% (slight under-extrusion) |
M290 |
Babystepping | Z |
Adjust Z offset in real-time during printing |
M290 Z-0.02 — lower nozzle 0.02mm closer to bed |
M350 |
Set Microstepping | X Y Z E |
Set microstepping mode for each axis |
M350 X16 Y16 — set X/Y to 16x microstepping |
M906 |
Set Motor Current | X Y Z E |
Set stepper driver current (mA) per axis |
M906 X800 Y800 — set X/Y motor current to 800mA |
| Command | Name | Key Parameters | Description | Example |
|---|---|---|---|---|
M0 |
Unconditional Stop | S |
Pause and wait for user. S=timeout seconds |
M0 S30 — pause, auto-resume after 30 seconds |
M25 |
Pause SD Print | — | Pause print running from SD card |
M25 — pause SD card print |
M73 |
Set Print Progress | P R |
Set progress percentage and remaining time |
M73 P50 R30 — 50% done, ~30 minutes left |
M80 |
ATX Power On | — | Turn on ATX power supply |
M80 — power on PSU |
M81 |
ATX Power Off | — | Turn off ATX power supply |
M81 — power off PSU (after cooldown!) |
M85 |
Inactivity Shutdown | S |
Set idle timeout before steppers disable |
M85 S300 — disable steppers after 5min idle |
M112 |
Emergency Stop | — | Immediately halt all motion and heaters |
M112 — emergency kill (requires reset to recover) |
M114 |
Get Current Position | — | Report current X/Y/Z/E coordinates |
M114 — prints X:100.00 Y:50.00 Z:0.30 E:12.50
|
M115 |
Firmware Info | — | Report firmware name, version, capabilities |
M115 — prints firmware name and version |
M119 |
Endstop Status | — | Report state of all endstop switches |
M119 — shows x_min: TRIGGERED etc. |
M155 |
Auto-Report Temps | S |
Auto-report temperatures every S seconds |
M155 S2 — report temps every 2 seconds |
M226 |
Pause (RRF) / Pin Wait | — | RRF: pause print. Marlin: wait for pin state |
M226 — pause print (RRF runs pause.g) |
M400 |
Wait for Moves | — | Wait until all buffered moves finish executing |
M400 — wait for motion buffer to empty |
M500 |
Save Settings | — | Save current settings to EEPROM/flash |
M500 — save current config to EEPROM |
M501 |
Load Settings | — | Load previously saved settings from EEPROM |
M501 — reload saved settings |
M503 |
Report Settings | — | Print all current firmware settings to console |
M503 — dump all settings to terminal |
M862 |
Printer Model Check | P Q |
Verify printer model/nozzle diameter matches G-code |
M862.3 P "MK3S" — verify printer is a MK3S |
M911 |
Power Loss Recovery | — | Resume print after power failure |
M911 — resume interrupted print |
| Command | Name | Key Parameters | Description | Example |
|---|---|---|---|---|
M42 |
Switch I/O Pin | P S |
Set pin P to value S (0-255) |
M42 P7 S255 — set pin 7 to high (255) |
M125 |
Park Head | X Y Z |
Park nozzle at specified position |
M125 X10 Y10 Z5 — park at X=10 Y=10 Z+5 |
M280 |
Set Servo Position | P S |
Move servo P to angle S (0-180) |
M280 P0 S90 — move servo 0 to 90 degrees |
M355 |
Case Light | S P |
Control case LED. S=on/off, P=brightness |
M355 S1 P200 — case light on at ~78% brightness |
Proprietary commands used by Bambu Lab printers (X1C, P1S, H2, H2D, H2C, A1, A1 mini). Reverse-engineered from Bambu Studio slicer output. See bambu-gcode-reference.md for full details with examples and confidence tags.
| Command | Name | Key Parameters | Description | Example |
|---|---|---|---|---|
M620 S |
Begin AMS Filament Select | S A |
Open AMS filament change block. S=slot (0-3, 255=unload) |
M620 S0A — begin selecting AMS slot 0 |
M620 M |
Enable AMS Remap | — | Allow AMS slot remapping when a spool runs out |
M620 M — enable slot remapping for backup spools |
M620.1 |
Flush Extrusion Params | E F T |
Set flush speed and temperature for filament purge |
M620.1 E30 F523 T240 — flush 30mm at 523mm/min, 240C |
M620.3 |
Tangle Detection | W |
Enable/disable filament tangle detection on AMS |
M620.3 W1 — enable AMS tangle detection |
M620.6 |
Air Print Detection | I W |
Enable AMS air printing detection per extruder |
M620.6 I0 W1 — enable air print detect on extruder 0 |
M620.10 |
Flush Sequence Control | A F L H T P S R |
Configure multi-phase purge tower flush. A=phase (0=pre, 1=post) |
M620.10 A0 F0.3 L10 H0.4 T200 P0.02 — pre-flush config |
M620.11 |
Retraction When Cut | S I E F P K O T H D R L |
Configure cutter-assisted retraction during filament changes |
M620.11 S1 I30 E3.5 F2000 — cut-retract: 30mm at 2000mm/min |
M620.14 |
Wipe Tower Center | X Y |
Set wipe/purge tower center position [H2C/H2D] |
M620.14 X150 Y200 — wipe tower at X=150 Y=200 |
M620.15 |
Flush Temp Params | P C |
Set pre-flush and cool-down temperatures [H2C] |
M620.15 P220 C180 — pre-flush 220C, cooldown 180C |
M621 |
End AMS Filament Select | S A |
Close AMS filament change block (paired with M620) |
M621 S0A — end AMS slot 0 selection |
M624 |
Start Printing Object | base64 label | Begin G-code for a specific object (exclude object feature) |
M624 Q2FsaWJyYXRpb24= — start printing "Calibration" object |
M625 |
Stop Printing Object | — | End G-code for object started by M624 |
M625 — end current object's G-code block |
M628 |
Begin Flush Sequence | S |
Start filament purge monitoring. S=mode (0=standard, 1=cut) |
M628 S0 — begin standard flush sequence |
M629 |
End Flush Sequence | S |
End filament purge sequence (paired with M628) |
M629 S0 — end flush sequence |
M630 |
Filament Sensor Reset | S P |
Reset filament runout sensor to known state |
M630 S0 P0 — reset runout sensor |
M632 |
Begin Nozzle Change | S M N |
Open nozzle change block for dual-nozzle [H2C] |
M632 S0 M0 N1 — switch from nozzle 0 to nozzle 1 |
M633 |
End Nozzle Change | — | Close nozzle change block (paired with M632) [H2C] |
M633 — end nozzle change sequence |
SYNC |
Flush Timing Sync | T |
Synchronize flush timing. T=delay seconds [H2C] |
SYNC T0.5 — sync with 0.5s delay |
| Command | Name | Key Parameters | Description | Example |
|---|---|---|---|---|
M640 S |
Begin Tool Operation | — | Start tool change sequence |
M640 S — begin tool change |
M640.1 R |
Retract Tool | — | Retract current tool from dock |
M640.1 R — retract tool into dock |
M640.1 S |
Select Tool | — | Select new tool |
M640.1 S — grab next tool from dock |
M640.2 |
Tool Release | R |
Release tool (R0=hold, R1=release) |
M640.2 R1 — release current tool |
M640.4 |
Tool Dock | — | Return tool to dock position |
M640.4 — dock current tool |
M640.7 |
Tool Lock/Unlock | L U |
Lock (L) or unlock (U) tool in place |
M640.7 L — lock tool in carriage |
M640.8 |
Select by Index | T A |
Select tool by AMS index |
M640.8 T0 A0 — select tool 0 from AMS 0 |
M641 |
End Tool Operation | — | Finalize tool change (paired with M640) |
M641 — finalize tool change |
M1009 |
Z-Homing Sensor Enable | Q L |
Activate/deactivate multi-head Z-homing sensor [H2C/H2D] |
M1009 Q1 L20 — enable Z sensor, L=offset |
M1012.5 |
Toolhead Offset Record | N R |
Record toolhead offset. N=nozzle index [H2D] |
M1012.5 N1 R0 — record nozzle 1 offset, no reset |
M1012.7 |
Toolhead Offset (Wipe) | — | Record toolhead offset after wipe check [H2C] |
M1012.7 — record offset post-wipe |
M1012.8 |
Position Cal Data | — | Record Z/position calibration data [H2C] |
M1012.8 — record Z-position cal data |
M1012.9 |
Secondary Cal Data | — | Record per-nozzle calibration data [H2C] |
M1012.9 — record per-nozzle cal data |
M1026 |
Begin Data Recording | — | Start calibration data recording session [H2C/H2D] |
M1026 — begin cal data session |
G383 |
Toolhead Offset Cal | O U L |
Calibrate toolhead XY offset [H2C/H2D] |
G383 O1 U1 L1 — run full offset calibration |
G383.3 |
Offset Cal Sub-Step | U L |
Sub-step of toolhead offset calibration |
G383.3 U1 L1 — calibration sub-step |
G383.7 |
Offset Cal Check | U J |
Post-wipe offset calibration verification |
G383.7 U1 J1 — verify offset after wipe |
G387 |
Safe Y Travel | Y J F |
Y-axis move with collision avoidance. J=enable [H2C] |
G387 Y200 J1 F6000 — safe Y move to 200 |
| Command | Name | Key Parameters | Description | Example |
|---|---|---|---|---|
M622 S |
If Flag Equals | S |
If flag value matches S, execute block |
M622 S1 — if flag is 1, run block until M623 |
M622 J |
If Judge Result | J |
If last judge_flag result matches (0=false, 1=true, 2=full cal) |
M622 J1 — if judge passed, run block |
M622.1 |
Set Default Flag | S |
Default flag for older firmware backward compatibility |
M622.1 S1 — set default flag for older FW |
M623 |
End Conditional | — | Close conditional block opened by M622 |
M623 — end if/else block |
| Command | Name | Key Parameters | Description | Example |
|---|---|---|---|---|
M73 (ext) |
Print Progress | P R L E |
Extended: L=layer number, E=extruder time remaining |
M73 P45 R22 L15 — 45% done, 22min left, layer 15 |
M73.2 |
Reset Time Estimate | R |
Reset remaining time magnitude (R1.0=normal) |
M73.2 R1.0 — reset time estimate to normal |
M201.2 |
Reset Accel Magnitude | K |
Reset acceleration scaling (K1.0=normal) |
M201.2 K1.0 — reset accel scaling |
M400 U1 |
Bambu Pause | — | Show pause dialog on touchscreen with audio alert |
M400 U1 — pause print with touchscreen prompt |
M991 |
Layer Change Notify | S P |
Notify system of layer change. P=layer number |
M991 S0 P10 — notify now on layer 10 |
M1002 |
System Control | string args | Multiplex: UI state, flags, filament type, speed level |
M1002 set_gcode_claim_speed_level 5 — set speed level 5 |
M1003 |
Power Loss Recovery | S |
Enable/disable power loss recovery [H2C/H2D] |
M1003 S1 — enable power loss recovery |
M1006 |
Sound/Buzzer | S A B L ... |
Play melodies — startup sounds, completion chimes |
M1006 S1 A10 B20 L200 — play a tone sequence |
M1007 |
Unknown Enable/Disable | S |
Purpose not yet determined — toggled during filament changes |
M1007 S1 — enable (purpose unknown) |
| Command | Name | Key Parameters | Description | Example |
|---|---|---|---|---|
M960 |
Laser/LED Control | S P |
S=device (1/2=laser, 5=logo, 10=fan LED), P=on/off |
M960 S5 P1 — turn on logo LED |
M970 |
Lidar Calibration Scan | Q A B C H K M O |
Build plate scan via lidar/visual sensor [X1C/A1] |
M970 Q1 A7 B30 C63 H15 K0 — lidar scan with params |
M970.2 |
Vibration Scan | Q K W Z |
Resonance frequency scan for input shaping [H2C/H2D] |
M970.2 Q1 K1 W80 Z0.3 — vibration scan at 80Hz |
M970.3 |
Edge Detection Scan | Q A K O |
Edge/object detection scan |
M970.3 Q1 A7 K0 O2 — edge detection scan |
M971 |
Camera Capture | S C O |
Capture camera frame (timelapse) |
M971 S11 C10 O0 — capture frame for timelapse |
M9711 |
Timelapse Extended | M E U V Z S C O T |
Capture with position data [H2C/H2D] |
M9711 M0 E0 U100 V50 Z5.2 S11 C10 O0 T1 — capture with XYZ |
M972 |
Safety Detection Scan | S P T C |
Safety checks: nozzle type, plate detect, collision [H2C/H2D] |
M972 S5 P0 — run nozzle type detection scan |
M974 |
Process Scan Results | Q S P |
Apply results from M970/M970.3 scan |
M974 Q1 S2 P0 — process lidar scan results |
M993 |
Nozzle Cam Detection | A B C |
Control nozzle camera detection (0=off, 1=on) [H2 series] |
M993 A1 B0 C0 — enable camera detection |
M1004 |
External Camera | S P |
Trigger external camera shutter for timelapse |
M1004 S1 P1 — trigger external camera |
| Command | Name | Key Parameters | Description | Example |
|---|---|---|---|---|
M900 (ext) |
Pressure Advance | K L M |
Bambu variant: L=lookahead distance, M=multiplier |
M900 K0.02 L20 M1.0 — PA with lookahead tuning |
M901 |
PA Configuration | D |
Pressure advance operating mode [H2 series] |
M901 D1 — set PA mode |
M975 |
Vibration Suppression | S |
Enable/disable input shaping / resonance compensation |
M975 S1 — enable input shaping |
M981 |
Spaghetti Detector | S P |
Enable/disable print failure detection [H2C/H2D] |
M981 S1 P20000 — enable spaghetti detection |
M982.2 |
Cog Noise Reduction | S |
Enable/disable stepper motor noise compensation |
M982.2 S1 — enable cog noise reduction |
M983 |
Extrusion Cal | F A H |
Run dynamic extrusion compensation calibration |
M983 F1.0 A0.1 H0.4 — run extrusion cal |
M983.1 |
Extrusion Cal Mode | M |
Set extrusion calibration mode [H2 series] |
M983.1 M1 — set cal mode 1 |
M983.3 |
Dynamic Extrusion Comp | F A R |
Configure dynamic compensation [H2 series] |
M983.3 F0.5 A0.1 R1 — dynamic comp with reset |
M983.4 |
Deformation Comp | S |
Enable/disable print deformation compensation [H2] |
M983.4 S1 — enable deformation comp |
M984 |
Apply Extrusion Comp | A E S F H |
Apply measured extrusion compensation values |
M984 A0.98 E1.02 S0.5 F500 H0.4 — apply comp values |
M9833 |
Extrusion Comp (Tool) | F A |
Re-calibrate compensation after tool change |
M9833 F1.0 A0.1 — recal after tool change |
M1015.3 |
TPU Clog Detection | S |
Enable TPU-specific clog detection (mutually exclusive with M1015.4) |
M1015.3 S1 — enable TPU clog detect |
M1015.4 |
Air Print Detection | S K H |
Detect air printing for rigid filaments (PLA, PETG) |
M1015.4 S1 K5 H100 — enable for rigid filaments |
| Command | Name | Key Parameters | Description | Example |
|---|---|---|---|---|
G28.14 |
Pre-Extrude Z Cal | R D |
Calibrate Z position before first extrusion [H2] |
G28.14 R5 D0 — Z cal with 5mm retract |
G28.140 |
Extended Z Cal | D S |
Extended Z calibration for tool changer [H2C] |
G28.140 D0 S1 — extended Z cal for tool changer |
G29.1 |
Z Offset for Bed Type | Z |
Apply Z offset per build plate type (e.g. -0.02 for textured PEI) |
G29.1 Z-0.02 — offset for textured PEI plate |
G29.2 |
Enable/Disable ABL | S |
Turn auto bed leveling mesh on or off |
G29.2 S1 — enable ABL mesh compensation |
G29.7 |
Position Compensation | S |
Enable additional positional accuracy for ABL [H2] |
G29.7 S1 — enable position compensation |
G29.9 |
Leveling Data Record | — | Record leveling calibration data [H2] |
G29.9 — record leveling data |
G29.20 |
ABL Mode Selection | A |
Select ABL probing mode (A3 or A4) [H2] |
G29.20 A4 — use 4-point ABL mode |
G29.99 |
Final Leveling Step | — | Finalize all leveling compensation data [H2] |
G29.99 — finalize leveling data |
G39 |
Nozzle Clog Scan | S X Y |
Scan for nozzle clogging or filament buildup |
G39 S1 X150 Y150 — clog scan at bed center |
G39.1 |
Clog Detection Cal | — | Calibrate nozzle clog detection position [H2] |
G39.1 — calibrate clog detect position |
G39.3 |
Mass Exceed Detection | S |
Scan for excess material buildup (spaghetti) |
G39.3 S1 — scan for spaghetti failure |
G39.4 |
Build Plate Detection | — | Verify build plate presence and type |
G39.4 — check build plate is present |
G150 |
Wipe Position | T |
Move to wipe station. T=temperature [H2 series] |
G150 T210 — move to wipe station at 210C |
G150.1 |
Wipe Mouth Move | F |
Wipe movement at station [H2 series] |
G150.1 F3000 — wipe at 3000mm/min |
G150.2 |
Wipe Variant | — | Alternate wipe position [H2 series] |
G150.2 — alternate wipe position |
G150.3 |
Safe Position Return | F |
Return to safe position after wipe [H2 series] |
G150.3 F6000 — return from wipe at 100mm/s |
G380 |
Z Move with Endstop | S Z F |
Z move with endstop control. S=mode (2=up, 3=down) |
G380 S2 Z10 F1200 — move Z up 10mm with endstop |
G392 |
Toggle Clog Detection | S |
Enable/disable nozzle clog detection system |
G392 S1 — enable clog detection |
| Command | Name | Key Parameters | Description | Example |
|---|---|---|---|---|
M142 |
Chamber Auto-Cooling | P R S T U V W O L |
Configure chamber cooling PID. Enclosed printers only |
M142 P1 R30 S45 T2 — chamber cooling PID config |
M145 |
Airduct Mode | P |
P=0 cooling mode, P=1 heating mode [H2 series] |
M145 P0 — set airduct to cooling mode |
M481 |
Cutter Position Comp | S |
Toggle filament cutter position compensation [H2 series] |
M481 S1 — enable cutter position comp |
M562 |
Extruder Selection | P E B |
Map physical extruder positions to indices [H2S] |
M562 P0 E0 B0 — map extruder 0 to position 0 |
M710 |
MC Fan Control | A S |
Control main controller board cooling fan [P1S] |
M710 A1 S200 — auto fan at 200/255 speed |
Klipper uses macro-based commands defined in printer.cfg. These are not traditional G/M codes but are commonly used.
| Command | Name | Description | Example |
|---|---|---|---|
PAUSE |
Pause Print | Pause with configured park position and retraction. Requires [pause_resume]
|
PAUSE — park nozzle and retract |
RESUME |
Resume Print | Resume after PAUSE with configured prime and return |
RESUME — prime and return to print |
CANCEL_PRINT |
Cancel Print | Cancel current print job |
CANCEL_PRINT — stop print, run end macro |
BED_MESH_CALIBRATE |
Bed Mesh | Probe bed and create leveling mesh (Klipper's G29 equivalent) |
BED_MESH_CALIBRATE PROFILE=default — probe and save mesh |
PROBE_ACCURACY |
Probe Test | Test Z-probe repeatability (Klipper's M48 equivalent) |
PROBE_ACCURACY SAMPLES=10 — test 10 probes |
Z_TILT_ADJUST |
Z Tilt | Align multiple Z motors (Klipper's G34 equivalent) |
Z_TILT_ADJUST — level gantry with 2+ Z motors |
DELTA_CALIBRATE |
Delta Cal | Calibrate delta geometry (Klipper's G33 equivalent) |
DELTA_CALIBRATE — run delta geometry cal |
QUAD_GANTRY_LEVEL |
QGL | Level a quad-gantry (Voron-style) by probing 4 corners |
QUAD_GANTRY_LEVEL — level all 4 Z motors |
SAVE_CONFIG |
Save Config | Save calibration results to printer.cfg (Klipper's M500 equivalent) |
SAVE_CONFIG — save and restart Klipper |
FIRMWARE_RESTART |
Firmware Restart | Restart Klipper MCU firmware without full reboot |
FIRMWARE_RESTART — restart MCU firmware |
SET_RETRACTION |
Set Retraction | Configure firmware retraction params at runtime | SET_RETRACTION RETRACT_LENGTH=0.8 RETRACT_SPEED=60 |
SET_PRESSURE_ADVANCE |
Set PA | Set pressure advance factor. ADVANCE=0.05 SMOOTH_TIME=0.04
|
SET_PRESSURE_ADVANCE ADVANCE=0.05 SMOOTH_TIME=0.04 |
SET_VELOCITY_LIMIT |
Velocity Limits | Override max velocity, accel, and jerk at runtime | SET_VELOCITY_LIMIT VELOCITY=300 ACCEL=5000 |
INPUT_SHAPER_CALIBRATE |
Input Shaper Cal | Run accelerometer-based input shaper calibration |
INPUT_SHAPER_CALIBRATE — run with ADXL345 |
PID_CALIBRATE |
PID Tune | Run PID autotune. HEATER=extruder TARGET=200
|
PID_CALIBRATE HEATER=extruder TARGET=210 |
Marlin-specific commands that extend standard G-code with additional features.
| Command | Name | Key Parameters | Description | Example |
|---|---|---|---|---|
M301 |
Set Hotend PID | P I D |
Set PID tuning values for hotend temperature control |
M301 P22.2 I1.08 D114.0 — set PID values |
M303 |
PID Autotune | S E C |
Run PID autotune. S=target temp, E=heater, C=cycles |
M303 S210 E0 C8 — autotune nozzle at 210C, 8 cycles |
M304 |
Set Bed PID | P I D |
Set PID tuning values for heated bed |
M304 P97.1 I1.41 D1675.16 — set bed PID |
M851 |
Z Probe Offset | X Y Z |
Set probe-to-nozzle offset for auto bed leveling |
M851 Z-1.5 — probe is 1.5mm above nozzle tip |
M871 |
Probe Temp Comp | V I |
Set probe temperature compensation table values |
M871 V25 I-0.02 — compensate probe drift at 25C |
| Command | Name | Key Parameters | Description | Example |
|---|---|---|---|---|
M569 |
Stepper Driver Config | S |
Set stepper driver stepping mode (StealthChop/SpreadCycle) |
M569 S1 X — X axis in SpreadCycle mode |
M593 |
Input Shaping | F D |
Configure input shaper. F=frequency, D=damping |
M593 F40 D0.15 — shape at 40Hz, 0.15 damping |
M603 |
Filament Change Config | L U |
Set load/unload lengths for M600 filament change |
M603 L0 U100 — 0mm load, 100mm unload |
M710 |
Controller Fan | S I A D |
Configure controller cooling fan speed and behavior |
M710 S255 A1 — full speed, auto mode |
M913 |
Set Hybrid Threshold | X Y Z E |
Set StealthChop/SpreadCycle switchover speed per axis |
M913 X100 Y100 — switch at 100mm/s |
M914 |
Sensorless Homing | X Y Z |
Set StallGuard sensitivity for sensorless homing |
M914 X64 Y64 — set stall sensitivity (higher=less sensitive) |
RepRapFirmware (RRF/Duet) commands that differ from or extend standard G-code.
| Command | Name | Key Parameters | Description | Example |
|---|---|---|---|---|
M226 |
Pause Print | — | Primary pause command in RRF. Runs pause.g macro |
M226 — pause and run pause.g |
M291 |
Display Message | P S R T |
Show message on LCD/web. S=title, R=response type, T=timeout |
M291 P"Check nozzle" S"Warning" R1 T10 — prompt with 10s timeout |
M550 |
Set Machine Name | P |
Set printer name shown in web interface |
M550 P"My Printer" — set name in DWC |
M552 |
Network Config | S P |
Enable/disable networking. S=enable, P=IP address |
M552 S1 P192.168.1.100 — enable with static IP |
M557 |
Probe Grid | X Y S P |
Define bed probing grid area and spacing for G29 |
M557 X10:190 Y10:190 S20 — 20mm grid spacing |
M558 |
Probe Config | P H F T |
Configure Z probe type, dive height, speed, and trigger |
M558 P5 H5 F120 T6000 — BLTouch, 5mm dive |
M574 |
Endstop Config | X Y Z S P |
Configure endstop type and position per axis |
M574 X1 S1 P"xstop" — X min endstop on pin "xstop" |
M584 |
Driver Mapping | X Y Z E |
Map stepper drivers to axes |
M584 X0 Y1 Z2 E3 — standard driver mapping |
M587 |
Add WiFi Network | S P |
Store WiFi credentials. S=SSID, P=password |
M587 S"MyNetwork" P"password123" — save WiFi creds |
RRF uses macro files (.g scripts on the SD card) instead of inline commands for many operations:
| Macro File | When It Runs |
|---|---|
homeall.g |
When G28 is called with no axis parameters |
homex.g / homey.g / homez.g
|
When G28 X, G28 Y, or G28 Z is called |
bed.g |
When G29 is called (defines probe points) |
pause.g |
When M226 or DWC pause is triggered |
resume.g |
When print is resumed after pause |
stop.g |
When M0 is called or print ends |
filament-change.g |
When M600 is called |
config-override.g |
Loaded by M501, saved by M500
|
| Firmware | Primary Pause | Alt Pause | Filament Change |
|---|---|---|---|
| Bambu Lab | M400 U1 |
M600 |
M1020 (AMS) |
| Klipper | PAUSE |
M600 (macro) |
M600 (macro) |
| Marlin | M0 |
M600, M25
|
M600 |
| RepRapFirmware | M226 |
M600, M0
|
M600 |
← Reference | Analysis Theory →
Getting Started
User Guide
Reference