Home / Tools / Cost, Tolerances & Reference / M-Code Reference Guide
Cost, Tolerances & Reference

M-Code Reference Guide

M-codes for Fanuc and Haas controls — spindle, coolant, tool change, program stop and subprogram calls — with the machine-specific differences that break a program moved between controls.

M-Code Reference Guide — Reference Data

Complete reference tables and engineering data for m-code reference guide. All values verified against ISO, ANSI, and manufacturer standards.

M-codes are not standard — and that matters

Unlike G-codes, ISO never fully standardised M-codes. The common ones agree across controls, but the moment you leave M00–M09 you are reading a machine-specific table. Anything this reference lists outside the universal set should be confirmed against the control's own manual before it goes into a program.

The distinction that catches people most often is M00 against M01. M00 stops the program unconditionally — spindle off, feed off, program halted until cycle start. M01 is a planned stop that only takes effect when the panel's optional-stop switch is on. A program that relies on M01 for a manual check behaves differently on the next machine, and if that switch is off the check never happens.

Worked example: calling a subprogram

Fanuc-style subprogram call. The main program loads the tool, positions, then calls O1001 twice to run the same pocket at two locations.

Tool changeT5 M06Spindle onS4000 M03First positionG54 X0 Y0Call subprogram O1001M98 P1001Repeat after offsetG55 X0 Y0 / M98 P1001End of programM30

Two families of subprogram call exist. Fanuc and its clones use M98 P… to call and M99 to return. Haas uses M97 for a local subprogram identified by an N-number and M198 for an external file. Combining the two — M98 on a Haas, M97 on a Fanuc — fails with an alarm, and it is one of the most common errors when a program is moved between machines.

Tool change

M06 without a preceding T word usually re-loads the tool already in the spindle rather than the one you intended. Always pair them on the same line (T5 M06) or on consecutive lines with nothing else between them.

Common M-code commands for CNC machine control

M-codes (miscellaneous functions) control non-motion machine operations: spindle, coolant, tool changes, program flow. While G-codes handle geometry, M-codes handle the machine. This reference covers standard M-codes across Fanuc, Haas, and comparable controls.

Frequently asked questions

Why does my CNC alarm when I put M06 on the same line as T?

Some controls require M06 on its own line. Others require Txx on one line, M06 on the next. Still others process both on the same line but activate them in a specific order. Check your machine manual. The safest format is: T12 (pre-stage the tool); M06 (change to staged tool). This pre-stages the next tool while the current tool is cutting.

What is the difference between M00, M01, and M30?

M00 = unconditional stop (program waits). M01 = conditional stop (waits only if Optional Stop switch is on). M30 = program end with rewind (resets program to the beginning). Use M00 for mandatory interventions, M01 for optional inspections, and M30 to end every program.

What M-codes are not standardised?

Auxiliary equipment M-codes vary by machine builder: pallet changer, chip conveyor, bar feeder, parts catcher, tailstock, steady rest, and air blast all use M-codes specific to the machine builder (M10-M99 range). Always check the machine's M-code list before using any M-code above M09 that you haven't verified.

How to use this M-Code Reference Guide

Use this reference to look up M-code functions and syntax. M03/M04/M05, M08/M09, M06, and M30 are the essential codes used in every CNC program. M-codes above M09 vary by machine -- always verify with the machine builder documentation before using machine-specific M-codes.

Common mistakes to avoid

Related references

Continue with closely related resources from the machining reference library.

Browse all free CNC machining calculators. Explore our carbide tooling resources for engineers and machinists.

Need carbide tooling for this operation?

Use the calculator freely. If the result points to a tooling or process problem, we can source the exact carbide tooling you need from vetted factories in China. Compare factory-direct pricing.

Price and process, before you send an RFQ

Before you commit to a spec, it helps to know what the market pays for it. These are real, publicly listed factory prices — not a quotation, and not a guess.

Carbide tooling for this calculation

We source the tool families below direct from vetted Chinese factories, matched to the material and tolerance you just worked out. Every batch ships with its material certificate and dimensional record.

Send your drawing for a 48-hour quotation → How our China sourcing works →

Global Engineering Directory

Explore more precision machining tools and calculators

SORTING OUT M-CODES? Control quirks and tool quirks get blamed for each other. When in doubt, start with what we verify on every tool before shipping.

Get the Carbide Tooling Reference — free PDF

We source carbide cutting tools from China for job shops. We do not own a factory, which is why we can quote your drawing against two or three plants that actually run your material.

Cutting formulas with the units worked through · Speed and feed starting points for all six ISO material groups · How to read a carbide grade past its ISO code. 12 pages.

Or send us a quote you already have — we will benchmark it free →