Full M-code list
Sorted by number, including each manufacturer's own codes. Each code links to its page.
| Code | What it does | Machine |
|---|---|---|
| M00/M01 | Mandatory / optional stop | Mill, Lathe, Mill-turn, Laser |
| M02 | End of program | Mill, Lathe, Mill-turn, Laser |
| M03/M04/M05 | Spindle control | Mill, Lathe, Mill-turn |
| M06 | Tool change | Mill, Mill-turn |
| M07 | Mist / auxiliary coolant | Mill, Lathe, Mill-turn |
| M08/M09 | Coolant | Mill, Lathe, Mill-turn |
| DN M10/M11 | Plate or clamp open/close DN/Doosan | Lathe, Mill-turn |
| M10/M11 | Clamping open/close | Lathe, Mill-turn |
| Okuma M10-M27 | Axis clamps and barriers | Mill, Lathe, Mill-turn |
| M12/M13 | Air blast | Mill, Lathe, Mill-turn |
| M13/M14 | Spindle with coolant / combined function | Mill, Lathe, Mill-turn |
| M14/M15 | Spindle brake / C-axis | Lathe, Mill-turn |
| M17/M18 | Turret indexing | Lathe, Mill-turn |
| M19 | Spindle orientation | Mill, Lathe, Mill-turn |
| M21/M22 | Tailstock advance/retract | Lathe, Mill-turn |
| M23/M24 | Threaded chamfer exit | Lathe, Mill-turn |
| M25-M29 | Bar feeder, parts catcher and lathe auxiliaries | Lathe, Mill-turn |
| M29 | Rigid thread preparation | Mill, Mill-turn |
| M30 | End of program | Mill, Lathe, Mill-turn, Laser |
| DN M31/M32 | DN/Doosan chip conveyor | Mill, Lathe, Mill-turn |
| M31/M32 | Chuck bypass / lathe auxiliary | Lathe, Mill-turn |
| M31/M33 | Haas chip conveyor | Mill, Lathe, Mill-turn |
| M35/M36/M37 | Parts catcher | Lathe, Mill-turn |
| M37/M38 | Conveyor or auxiliary function | Mill, Lathe, Mill-turn |
| M38/M39 | Spindle speed variation | Lathe, Mill-turn |
| M41/M42 | Low/high spindle gear range | Mill, Lathe, Mill-turn |
| M43/M44 | Tool setter / turret lock | Lathe, Mill-turn |
| M48/M49 | Enable/disable override | Mill, Lathe, Mill-turn |
| Okuma M50-M54 | Coolant per tool and return cycle | Mill, Mill-turn |
| M51-M56/M61-M66 | Integrated M-code relays | Mill, Lathe, Mill-turn, Laser |
| M52/M53 | Adaptive feed control / feed stop | Mill, Lathe, Mill-turn |
| M53-M56 | Steady rest and tailstock clamp/unclamp | Lathe, Mill-turn |
| Okuma M55/M56 | Tailstock retract/advance | Lathe, Mill-turn |
| Okuma M58/M59 | Low/high clamping pressure | Lathe, Mill-turn |
| M60 | Pallet change | Mill, Mill-turn |
| M62-M65 | Auxiliary outputs / PLC | Mill, Lathe, Mill-turn, Laser |
| M68/M69 | Hydraulics / auxiliary output | Lathe, Mill-turn |
| M70/M71 | Mirror / cancel mirror (some Fanuc) | Mill, Mill-turn |
| Okuma M73-M75 | Threading patterns | Lathe, Mill-turn |
| M78/M79 | Skip signal alarms | Mill, Lathe, Mill-turn |
| M80/M81 | APC pallet changer | Mill, Mill-turn |
| Mazak M81-M84 | Piece/tool measurement | Lathe, Mill-turn |
| Okuma M83/M84 | Chuck clamp/unclamp | Lathe, Mill-turn |
| Haas M85/M86 | Door, clamping or optional interlock | Mill, Lathe, Mill-turn |
| Haas M88/M89 | Coolant through Haas spindle | Mill, Mill-turn |
| Mazak M90/M91 | Mazak main chuck clamping | Lathe, Mill-turn |
| M94/M95/M96 | Mirror image via M-code | Mill, Mill-turn |
| Mazak M96/M198/M199 | Macro and EIA/Mazatrol switching | Mill, Lathe, Mill-turn |
| Haas M97 | Haas local subprogram | Mill, Lathe, Mill-turn |
| M97 | Local subprogram / part counter | Mill, Lathe, Mill-turn |
| M98/M99 | Subprogram / return | Mill, Lathe, Mill-turn |
| Haas M109 | Wait at spindle speed | Mill, Lathe, Mill-turn |
| Mazak M110/M111 | Mazak automatic door control | Mill, Lathe, Mill-turn |
| Okuma M116/M117 | Safety barrier / chuck barrier | Lathe, Mill-turn |
| M121-M129 | Relays with M-Fin | Mill, Lathe, Mill-turn |
| M130/M131 | Show/cancel media | Mill, Lathe, Mill-turn |
| M133/M134/M135 | motorized lathe tool | Lathe, Mill-turn |
| Mazak M150-M153 | Integrex robot, air blast and coolant | Lathe, Mill-turn |
| Okuma M152/M153/M168/M169 | Powered tool and C axis | Lathe, Mill-turn |
| M154/M155 | Engage/disengage C axis | Lathe, Mill-turn |
| M158/M159 | Mist extractor | Mill, Lathe, Mill-turn |
| Okuma M191/M192 | Powered tool orientation | Lathe, Mill-turn |
| M198 | External subprogram call (USB/card) | Mill, Lathe, Mill-turn |
| Haas M199 | Automatic start next program | Mill, Lathe, Mill-turn |
| Mazak M200-M205 | Lathe/mill and live tool mode | Lathe, Mill-turn |
| Okuma M201-M220 | Okuma M-code macros | Mill, Lathe, Mill-turn |
| Mazak M210-M283 | Expanded Integrex Automation | Lathe, Mill-turn |
| Okuma M211-M214 | Keyway cutting | Lathe, Mill-turn |
| M299/M300 | APL/robot and custom sequence | Mill, Lathe, Mill-turn |
| M334/M335 | P-Cool setting | Mill, Mill-turn |
| M373/M374 | Tool Air Blast | Mill, Mill-turn |
| M388/M389 | Advanced through-spindle coolant | Mill, Mill-turn |
| DMG Mori M-codes | DMG Mori auxiliary functions | Mill, Lathe, Mill-turn |
| Hermle M-codes | Hermle auxiliary functions | Mill, Mill-turn |
| Mazak M-codes | Mazak auxiliary M-codes | Mill, Lathe, Mill-turn |
| Okuma M-codes | Okuma auxiliary functions | Mill, Lathe, Mill-turn |
01The basic M-codes are almost universal
M03, M04 and M05 run the spindle clockwise, counter-clockwise or stop it; M08 and M09 switch coolant on and off; M06 changes the tool on a mill; M00 stops the program and M01 only stops if the operator enables optional stop; M30 ends the program and rewinds, and M98/M99 call and close subprograms. That covers most programs.
02Many M-codes are defined by the machine builder
Beyond the basics, the number is assigned by the machine builder, not the control: the same M-code may open the chuck on one lathe, move the tailstock on another or not exist on a third. Haas, Mazak, Okuma, DN Solutions, DMG Mori and Hermle publish their own tables. Before using an M-code you do not know, look it up in your machine manual, not the control manual.
03One M per block, and when it acts
Many controls accept only one M-code per block unless a parameter allows more, so the safe habit is one per line. Depending on the machine, an M-code may also act at the start of the block (before the move) or at the end: that is why it is good practice to program M05, M09 or the tool change in a block of their own, with the tool already retracted.
04M02 and M30 are not the same
Both end the program, but M30 also rewinds to the start for the next part, while on many controls M02 stays at the end. Production programs use M30; M02 is mostly found in older programs.
Frequently asked questions
What is an M-code?
It is a miscellaneous function in a CNC program: it switches something on the machine on or off, such as the spindle, coolant, tool change, a stop or the end of program. It does not move the axes by itself.
What does M03 do and how is it different from M04?
M03 turns the spindle clockwise and M04 counter-clockwise, at the rpm set by S. M05 stops it.
What is the difference between M00 and M01?
M00 always stops the program until the operator presses cycle start; M01 only stops if optional stop is enabled on the panel. M01 is used to inspect parts without stopping every cycle.
Why does an M-code not work the same on two machines?
Because, apart from the basic ones, each builder assigns its own numbers to functions such as the chuck, tailstock or bar feeder. Check your machine manual before using it.
General reference: syntax and meaning change with the control, the machine builder and machine parameters. Check the official manual before running a program. Last updated: