M-codes (miscellaneous or machine codes) control machine functions rather than motion: the spindle, coolant, tool changer, and program flow. Exact codes vary by machine, but a common core is nearly universal.
| Code | Function |
|---|---|
| M00 | Program stop (resume with cycle start) |
| M01 | Optional stop (only if the switch is on) |
| M02 | Program end |
| M03 / M04 | Spindle on clockwise / counterclockwise |
| M05 | Spindle stop |
| M06 | Tool change |
| M08 / M09 | Coolant on / off |
| M19 | Spindle orient |
| M30 | Program end and rewind |
| M98 / M99 | Call / return from subprogram |
Always confirm M-codes against your specific controller manual — assignments above M30 differ between builders.
Related: the G-Code Cheat Sheet and Machining Glossary.
