M-Code Reference

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.

Scroll to Top

The calculators and tools on Formula Factory are provided for general guidance and informational purposes only. Results are estimates based on standard formulas and the values you enter — they do not constitute professional engineering, electrical, or architectural advice. Always verify calculations with a qualified professional before making decisions for any safety-critical, code-compliance, or commercial application. Formula Factory makes no representations or warranties as to the accuracy or completeness of any result, and accepts no liability for errors, omissions, or any outcomes arising from reliance on this information.