G and M codes for machining centers (Fanuc-type mills)
This page lists the G codes of Fanuc-type machining centres (vertical and horizontal mills) and the M codes that matter most on them. Most mill controls follow the Fanuc numbering, but cycles, options and a few code numbers differ between machine builders and control versions, so check your machine's programming manual before you rely on a code. For the full list of standard M codes see the M code list; for lathes see the lathe G codes, where several numbers mean something else.
G codes for machining centres
| Code | Function |
|---|---|
| G00 | Rapid positioning |
| G01 | Linear interpolation (feed) |
| G02 | Circular interpolation, clockwise |
| G03 | Circular interpolation, counterclockwise |
| G04 | Dwell |
| G09 | Exact stop (one block) |
| G10 | Programmable data input (offsets, work coordinates) |
| G15 / G16 | Polar coordinates off / on |
| G17 / G18 / G19 | Plane selection XY / ZX / YZ |
| G20 / G21 | Inch / metric input |
| G28 | Return to reference point (machine zero) |
| G30 | Return to 2nd reference point |
| G31 | Skip function (probing) |
| G40 | Cutter radius compensation cancel |
| G41 / G42 | Cutter radius compensation left / right |
| G43 / G44 | Tool length compensation + / - |
| G49 | Tool length compensation cancel |
| G50 / G51 | Scaling off / on |
| G50.1 / G51.1 | Programmable mirror image off / on |
| G52 | Local coordinate system |
| G53 | Machine coordinate system (one block) |
| G54 - G59 | Work coordinate systems 1 to 6 |
| G61 | Exact stop mode |
| G64 | Cutting mode (cancels G61) |
| G65 | Macro call |
| G66 / G67 | Modal macro call / cancel |
| G68 / G69 | Coordinate rotation on / off |
| G73 | High-speed peck drilling cycle |
| G74 | Left-hand (reverse) tapping cycle |
| G76 | Fine boring cycle |
| G80 | Canned cycle cancel |
| G81 | Drilling cycle (spot drilling) |
| G82 | Drilling cycle with dwell (counterboring) |
| G83 | Peck drilling cycle |
| G84 | Tapping cycle |
| G85 | Boring cycle (feed in, feed out) |
| G86 | Boring cycle (spindle stop, rapid out) |
| G87 | Back boring cycle |
| G88 | Boring cycle (dwell, spindle stop, manual retract) |
| G89 | Boring cycle (dwell, feed out) |
| G90 / G91 | Absolute / incremental programming |
| G92 | Work coordinate system setting (shift) |
| G94 / G95 | Feed per minute / per revolution |
| G98 / G99 | Canned cycle return to the initial point / to the R point |
Builders differ in places. For example, Haas mills use G77 for back boring and G87 for a boring cycle with manual retract, and the meaning of their G52 depends on a setting. On mills G98 and G99 select the return level of drilling cycles; on lathes with G code system A the same numbers set feed per minute and per revolution.
M codes on machining centres
| Code | Function on most Fanuc-type mills | Note |
|---|---|---|
| M00 | Program stop | |
| M01 | Optional stop | only when the optional stop switch is on |
| M02 | End of program | |
| M03 / M04 | Spindle on, clockwise / counterclockwise | |
| M05 | Spindle stop | |
| M06 | Tool change | |
| M07 | Second coolant on | often mist or air; set by the builder |
| M08 | Coolant on (flood) | |
| M09 | Coolant off | |
| M19 | Spindle orientation | stops the spindle at a fixed angle |
| M29 | Rigid tapping mode | on many Fanuc-type mills; the number is set by a parameter, and Haas mills use M29 for an output relay |
| M30 | End of program and rewind | |
| M98 | Subprogram call | handled by the control itself |
| M99 | Subprogram end / return | handled by the control itself |
All other M codes are defined by the machine builder. Examples from Haas mills: M10 / M11 engage / release the 4th-axis brake, M12 / M13 engage / release the 5th-axis brake, M31 / M33 start / stop the chip conveyor, M88 / M89 switch through-spindle coolant on / off. The M code list compares more codes on mills and lathes.
CNC Syntax Editor highlights these codes in mill programs and, in the Enterprise edition, backplots the tool path so you can check a program before it runs (G-code simulator). For a quick look in your browser use the free online G-code viewer. The Free Edition is on the download page.
Sources: Fanuc-type G and M code conventions; builder examples from the Haas mill M-codes and mill G-codes pages, checked 2 November 2026.
M codes | G codes | G and M codes for mills | ISO tape codes | EIA tape codes | Online G-code viewer