โ† Open Viewer
GCodex โ€บ G-Code Guide โ€บ Klipper G-Code

Klipper G-Code Reference: Complete Command Guide

All Klipper G-Code and extended commands โ€” standard motion codes, temperature, Klipper-specific macros, pressure advance, input shaper, and SAVE_CONFIG. Updated May 2026.

Quick Answer: Klipper supports all standard G-Code commands (G0, G1, G28, M104, M109, etc.) but adds powerful extensions: GCODE_MACRO for custom commands, SET_PRESSURE_ADVANCE for elasticity compensation, RESONANCE_TESTER for input shaping, and SAVE_CONFIG instead of M500 for persistent settings.

Klipper vs Marlin: Key Differences

FeatureKlipperMarlin
ProcessingRaspberry Pi (host) + MCU motionArduino/32-bit MCU only
Config fileprinter.cfg (text)Configuration.h (compile)
EEPROM saveSAVE_CONFIGM500
Pressure advanceBuilt-in, per-extruderLinear advance (M900)
Input shaperBuilt-in with ADXL345Not standard
MacrosPython-based GCODE_MACROG-Code only M600/scripts
Max speed500+ mm/s (motion handled on host)Typically 200โ€“300 mm/s
Update methodGit pull + restartFlash firmware

Standard G-Code Commands in Klipper

Klipper supports all RS-274 standard commands. Key ones:

  • G0 / G1 โ€” Rapid and feed moves (same as Marlin)
  • G2 / G3 โ€” Clockwise / counter-clockwise arc
  • G4 P[ms] โ€” Dwell/pause for milliseconds
  • G28 โ€” Home all axes
  • G29 โ€” Auto bed leveling (if probe configured)
  • G90 / G91 โ€” Absolute / incremental mode
  • G92 E0 โ€” Reset extruder position
  • M104 / M109 โ€” Hotend temperature (non-blocking / blocking)
  • M140 / M190 โ€” Bed temperature (non-blocking / blocking)
  • M106 / M107 โ€” Fan control
  • M503 โ€” Not used. Use DUMP_CONFIG instead.
  • M500 โ€” Not used. Use SAVE_CONFIG instead.

Klipper-Specific Commands

Pressure Advance

SET_PRESSURE_ADVANCE ADVANCE=0.05         ; Set pressure advance value
SET_PRESSURE_ADVANCE ADVANCE=0.05 SMOOTH_TIME=0.04  ; With smooth time

Pressure advance compensates for filament elasticity. Calibrate by printing a PA tower or line and measuring corner sharpness. Typical values: 0.02โ€“0.08 for direct drive, 0.3โ€“0.8 for Bowden.

Input Shaper (Resonance Compensation)

MEASURE_AXES_NOISE           ; Check accelerometer noise floor
SHAPER_CALIBRATE             ; Auto-calibrate resonances (ADXL345 required)
SET_INPUT_SHAPER SHAPER_FREQ_X=50 SHAPER_FREQ_Y=48  ; Manual set
SAVE_CONFIG                  ; Save to printer.cfg

SAVE_CONFIG (replaces M500)

SAVE_CONFIG   ; Write all pending calibration values to printer.cfg
              ; Klipper restarts after this command

GCODE_MACRO (custom commands)

[gcode_macro START_PRINT]
gcode:
    G28
    BED_MESH_CALIBRATE
    G1 Z5 F3000
    M109 S{printer.extruder.target}
    G92 E0

Bed Mesh Leveling

BED_MESH_CALIBRATE        ; Probe bed and build mesh
BED_MESH_PROFILE SAVE=default  ; Save mesh profile
BED_MESH_PROFILE LOAD=default  ; Load saved mesh

PID Tuning

PID_CALIBRATE HEATER=extruder TARGET=210  ; Auto-tune hotend
PID_CALIBRATE HEATER=heater_bed TARGET=60  ; Auto-tune bed
SAVE_CONFIG                                ; Save results

Stepper Motor Control

STEPPER_BUZZ STEPPER=stepper_x   ; Test individual stepper
SET_STEPPER_ENABLE STEPPER=extruder ENABLE=0  ; Disable extruder motor

Klipper Start Script Example

G28                    ; Home all axes
BED_MESH_PROFILE LOAD=default  ; Load saved bed mesh
G1 Z5 F3000            ; Safe height
M190 S60               ; Wait for bed temp
M109 S215              ; Wait for hotend temp
G92 E0                 ; Reset extruder
G1 X5 Y10 F3000        ; Move to purge position
G1 X70 E8 F900         ; Purge line
G92 E0                 ; Reset after purge

Frequently Asked Questions

Is Klipper G-Code different from Marlin G-Code?
Klipper supports all standard G-Code commands but uses different commands for saving settings (SAVE_CONFIG vs M500) and adds powerful extensions like SET_PRESSURE_ADVANCE, SHAPER_CALIBRATE, and a full Python macro system via GCODE_MACRO.
What is pressure advance in Klipper?
Pressure advance compensates for filament elasticity. Set with SET_PRESSURE_ADVANCE ADVANCE=0.05. It pre-pressurizes before corners and releases pressure after, giving sharper corners and less stringing than retraction alone.
How do I save settings in Klipper?
Use SAVE_CONFIG instead of M500. Klipper writes calibration data directly to printer.cfg and restarts. There is no EEPROM in Klipper โ€” all settings live in printer.cfg on the Raspberry Pi.