Reference49 entries7 controllers
M-code List
This M-code list has all 49 M-codes in the G-Code Guru reference, grouped by job: program stops and ends, spindle, coolant, tool change, clamps and subprograms. G-codes command motion and modes; M-codes switch machine functions: M03 starts the spindle, M08 turns on flood coolant, M06 changes the tool and M30 ends and rewinds the program. For the Fanuc meaning of each code and its notes, see the Fanuc M-code list.
Codes shown in colour link to a full page with a worked example, controller differences and what goes wrong on the shop floor. Sort by any column or type to filter.
Lists for one controlFanucHaas LatheHaas MillMazakOkuma OSPSiemens SINUMERIK
Program control 21
Stops and ends (M00, M01, M02, M30), mirror image (M21 to M23), part counters (M36, M37), feed override lock-out (M48, M49), pallet change (M60), the Haas M97 local call, and the printer-side stepper and message codes.
| M00 | Program StopUnconditional program stop. Machine stops and waits for operator to press cycle start. Spindle, coolant, and feed are stopped. |
| M01 | Optional StopConditional program stop. Machine stops only if Optional Stop switch is ON. Allows operator to skip stops during production runs. |
| M02 | Program EndEnds the program. Stops spindle, coolant, and feed. Cursor stays at M02 line. Does not rewind program. |
| M21 | Mirror X-Axis OnEnables X-axis mirroring. All X coordinates are reversed. Used for symmetric parts. |
| M22 | Mirror Y-Axis OnEnables Y-axis mirroring. All Y coordinates are reversed. Used for symmetric parts. |
| M23 | Mirror OffCancels both X and Y axis mirroring. Returns to normal coordinate interpretation. |
| M30 | Program End and RewindEnds the program and rewinds to the beginning. Stops spindle, coolant, and feed. Standard program ending code. |
| M36 | Part Counter IncrementIncrements the part counter by one. Used for production tracking and batch counting. |
| M37 | Part Counter DecrementDecrements the part counter by one. Used to correct count after scrapped parts. |
| M48 | Enable Feedrate OverrideEnables feedrate override. Allows operator to adjust feed rate percentage during cutting. |
| M49 | Disable Feedrate OverrideDisables feedrate override. Machine runs at exactly programmed feed rate, ignoring override knob. |
| M60 | Pallet ChangeExecutes automatic pallet change on machines with pallet changer. Swaps workholding pallet for automated production. |
| M82 | Absolute ExtrusionSets extruder to absolute positioning mode. E values represent total filament extruded from start. |
| M83 | Relative ExtrusionSets extruder to relative positioning mode. E values represent filament for each move only. |
| M84 | Disable SteppersDisables stepper motors after a period of inactivity, or immediately if no time specified. Saves power and reduces noise. |
| M97 | Local Subprogram CallCalls a local subprogram within the same program file. Jumps to a block with the specified N number and executes until M99 is encountered, then returns. |
| M117 | Display MessageDisplays a text message on the printer's LCD screen. Useful for showing progress updates, instructions, or status messages during a print. |
| M200 | Set Filament DiameterSets the filament diameter for volumetric extrusion mode. When enabled, E values represent cubic millimeters instead of linear filament length. |
| M400 | Wait for Moves to FinishWaits for all buffered moves to complete before processing the next command. Ensures synchronization. |
| M420 | Bed Leveling StateControls the bed leveling compensation. Can enable/disable stored mesh and show leveling data. |
| M600 | Filament ChangeInitiates a filament change sequence. Pauses print, retracts filament, and prompts user to load new filament. |
Spindle control 9
M03, M04 and M05 start and stop the spindle, M13 and M14 start it with coolant in the same block, M19 orients it, M29 switches rigid tapping on and M41, M42 pick the gear range.
| M03 | Spindle On CWStarts the spindle rotating clockwise (when viewed from above on a vertical mill, or from the tailstock on a lathe). Standard direction for right-hand tooling. |
| M04 | Spindle On CCWStarts the spindle rotating counter-clockwise. Used for left-hand tooling, left-hand tapping, and specific operations. |
| M05 | Spindle StopStops the spindle rotation. Should be called before tool changes and at program end. |
| M13 | Spindle CW + Coolant OnStarts spindle clockwise and turns on coolant simultaneously. Combines M03 and M08 in one command. |
| M14 | Spindle CCW + Coolant OnStarts spindle counter-clockwise and turns on coolant simultaneously. Combines M04 and M08. |
| M19 | Spindle OrientationOrients the spindle to a specific angular position and locks it. Required for tool changes with orientation, some boring cycles, and live tooling operations. |
| M29 | Rigid TappingActivates rigid tapping mode where the spindle and Z-axis are electronically synchronized. Provides more accurate threading than floating tap holders, especially in harder materials. |
| M41 | Low Gear SelectSelects low gear range on machines with gear-driven spindles. Provides higher torque at lower RPM. |
| M42 | High Gear SelectSelects high gear range on machines with gear-driven spindles. Provides higher RPM at lower torque. |
Coolant 5
M07 mist, M08 flood and M09 off, plus the M106 and M107 part-cooling fan on printers. Which pump a number drives is decided by the machine builder, not the control.
| M07 | Mist Coolant OnActivates mist coolant (air/oil mixture). Provides lubrication with minimal coolant volume. Good for aluminum and where flood coolant is undesirable. |
| M08 | Flood Coolant OnActivates flood coolant. Standard coolant delivery for most machining operations. Provides cooling, lubrication, and chip evacuation. |
| M09 | Coolant OffTurns off all coolant (both mist and flood). Should be called before tool changes and at program end. |
| M106 | Part Cooling Fan OnTurns on the part cooling fan at the specified speed. Essential for PLA, bridges, and overhangs. |
| M107 | Part Cooling Fan OffTurns off the part cooling fan. Equivalent to M106 S0. |
Tool change 1
M06 hands over to the machine's own tool change sequence. What retracts, orients and swaps is the builder's macro or ladder, so the same M06 runs differently on every machine.
| M06 | Tool ChangeExecutes automatic tool change. Swaps the current tool for the tool specified by the preceding T command. Machine goes through its tool change sequence. |
Clamps and fixtures 4
M10 and M11 clamp and release a rotary axis or fixture; M50 and M51 do the same for a pallet.
| M10 | ClampActivates workholding clamp or 4th axis clamp. Specific function varies by machine configuration. |
| M11 | UnclampReleases workholding clamp or 4th axis clamp. Specific function varies by machine configuration. |
| M50 | Pallet ClampClamps the pallet on machines with pallet systems. Ensures pallet is secured before machining. |
| M51 | Pallet UnclampUnclamps the pallet for removal or pallet change. |
Subprograms 2
M98 calls a subprogram and M99 returns from it, or loops the main program when there is nothing to return to.
| M98 | Subprogram CallCalls a subprogram. Execution transfers to the subprogram and returns to the next line after M98 completes. |
| M99 | Subprogram ReturnReturns from a subprogram to the calling program. Execution continues at the line after the M98 call. |
Lubrication and printer temperatures 7
Way lubrication (M32, M33) and the printer heater codes M104 to M190.
| M32 | Lubrication OnActivates automatic lubrication cycle. Lubricates machine slideways and ballscrews. |
| M33 | Lubrication OffDeactivates automatic lubrication or cancels manual lube cycle. |
| M104 | Set Extruder TemperatureSets the target temperature for the extruder (hotend). Does not wait for temperature to be reached - continues immediately. |
| M105 | Report TemperaturesReports current temperatures of all heaters (extruder, bed, chamber). Output includes current and target temperatures. Used for monitoring and host communication. |
| M109 | Wait for Extruder TemperatureSets extruder temperature and waits for it to be reached before continuing. Blocks execution until at temperature. |
| M140 | Set Bed TemperatureSets the target temperature for the heated bed. Does not wait - continues immediately. Use M190 to wait. |
| M190 | Wait for Bed TemperatureSets bed temperature and waits for it to be reached. Blocks execution until bed is at target temperature. |
Descriptions are the one-line entries from the app's reference database. Controller support marks whether a code exists in that dialect, not that it behaves identically; the full pages cover the differences.
By controller
The same list filtered to one control, with the dialect notes that matter on that machine.
Frequently asked questions
What is the difference between M00 and M01?
M00 stops the program every time: spindle, coolant and feed stop, and the machine waits for Cycle Start. M01 does the same only when the optional stop switch on the control panel is on; with the switch off the block is skipped. Put an M00 where the operator must act (flip the part, deburr, inspect) and an M01 where a stop helps on a proving run but would slow a production run.
Is M30 the same as M02?
Both end the program and stop the spindle, coolant and feed. M30 also rewinds to the top, so the program is ready to run again; M02 leaves the cursor on the M02 block. On a Haas, Setting 56 (M30 Restore Default G) decides whether M30 also puts the modal G codes back to their defaults, which is why a program that relies on modal state can behave differently on its second run.
Is M08 the same on Fanuc and Haas?
M08 is flood coolant on and M09 is coolant off on both. M07 is where they part: on a Fanuc-based mill M07 is mist, while on a Haas mill M07 is the optional shower coolant, so a post that writes M07 for mist runs the shower pump instead. Through-spindle coolant is separate again, M88 on and M89 off on a Haas. See M07, M08 and M09: coolant.
Why does M06 behave differently on different machines?
Because M06 is not a control function. On a Fanuc, parameter 6071 holds the M code that calls program O9001, so the tool change is a subprogram written by the machine builder, and the retract, orient and arm sequence is theirs. Siemens selects with T and activates the tool and its offset with M6. Grbl v1.1 does not support M6 at all and stops the stream with error:20; Marlin changes tools with the T word alone. See M06: tool change.
Do Grbl and Marlin use the same M-codes as a Fanuc?
Only the low numbers, and not all of those. Grbl v1.1 has M8 and M9 built in but M7 only when ENABLE_M7 is uncommented in config.h, and no M6. Marlin has M7, M8 and M9 only with COOLANT_CONTROL enabled, and a stock printer build answers "Unknown command" and carries on. Both use the T word rather than an M code to select a tool, and Marlin's own M104 to M190 heater codes have no equivalent on a machine tool.
Updated 24 Oct 2026