What M851 means
In Marlin, X and Y describe the probe's horizontal location relative to the nozzle, while Z describes the trigger height relationship. The correct sign follows Marlin's documented convention and must be measured on the actual machine. Changing the value does not rewrite an existing bed mesh, but it affects later probe use.
Klipper calibrates z_offset with PROBE_CALIBRATE and SAVE_CONFIG instead of built-in M851. RepRapFirmware implements M851 mainly for Marlin compatibility with a sign reversal relative to its preferred G31 Z form. Never transfer a number across firmware without rechecking the convention.
Syntax and parameters
M851 [X<offset>] [Y<offset>] [Z<offset>]X / YHorizontal probe-to-nozzle offsets in millimeters on supported Marlin builds.
ZVertical probe trigger offset in millimeters; sign convention is firmware-specific.
No parametersFirmware-specific report behavior; consult the target version before relying on it.
Practical examples
Set a Marlin Z offset
M851 Z-2.0Records a probe trigger point 2.0 mm below the nozzle under Marlin's convention; the real value must be measured.
Set horizontal offsets
M851 X-1.70 Y-1.30Places the probe 1.70 mm left and 1.30 mm in front of the nozzle under Marlin's coordinate convention.
Firmware context
| System | Status | What changes |
|---|---|---|
| Marlin | Common | Primary command for XYZ probe-to-nozzle offsets when a bed probe is configured; M500 can persist supported settings. |
| Klipper | Check dialect | Uses PROBE_CALIBRATE and the probe z_offset configuration; M851 is not a documented built-in calibration command. |
| RepRapFirmware | Check dialect | Provides M851 for compatibility, maps it to G31 with a reversed Z sign, and recommends G31 instead. |
| CNC controllers | Not applicable | Not applicable to general CNC probe offset configuration. |
What this viewer can show
The viewer does not apply M851 to coordinates, meshes or the first layer. It cannot measure the physical nozzle-probe relationship or determine whether the saved value is safe.
Common mistakes
- Sign conventions differ across firmware; a copied value can move the nozzle the wrong way.
- Mechanical changes can invalidate a previously measured offset.
- Changing an offset does not prove that homing, probing, mesh data or first-layer calibration is correct.
Primary sources
This page is an original explanation, reviewed against the firmware documentation below. Always confirm commands against the firmware and configuration on the machine that will execute them.