Printed from Kezuriba (kezuriba.net/en/nc/)
G-CODE · M-CODEG-code and M-code list
G and M codes for machining centers and lathes, centered on the common FANUC-type assignments. The same number can mean different things on different machines (M codes in particular are assigned by the machine builder). Always confirm against your machine’s manual before running a program.
Most-used M codes (common FANUC-type assignments; they differ by machine builder and model, so your machine’s manual comes first): M03 spindle forward, M05 spindle stop, M06 tool change, M08 coolant on, M09 coolant off, M30 program end and rewind, M98 subprogram call.
M code list · Quick comparison between controls · Codes whose numbers clash · Exact stop (G09, G61) · Decimal point input: is X1000 1000 mm or 1 mm? · CNC programming practice problems (30, graded)
Same number,
different machine?
Check the manual!

G codes
| Code | Machining center | Lathe (system A) | Modal |
|---|---|---|---|
| G00 | Rapid positioning (rapid traverse) | Rapid positioning (rapid traverse) | Modal (01) |
| G01 | Linear interpolation (cutting feed) | Linear interpolation (cutting feed) | Modal (01) |
| G02 | Circular interpolation, clockwise (CW) / helical interpolation | Circular interpolation, clockwise (CW) / helical interpolation | Modal (01) |
| G03 | Circular interpolation, counterclockwise (CCW) / helical interpolation | Circular interpolation, counterclockwise (CCW) / helical interpolation | Modal (01) |
| G04 | Dwell (pause) | Dwell (pause) | One-shot (00) |
| G07.1 | Cylindrical interpolation | Cylindrical interpolation | Modal |
| G09 | Exact stop (this block only) | Exact stop (this block only) | One-shot (00) |
| G10 | Programmable data input (writes offset values and work coordinates from the program) | Programmable data input (writes offset values and work coordinates from the program) | One-shot (00) |
| G12.1–G13.1 | Polar coordinate interpolation (ON with G12.1, OFF with G13.1) | Polar coordinate interpolation (ON with G12.1, OFF with G13.1) | Modal |
| G17 | XY plane selection | XY plane selection (used on lathes with milling capability) | Modal (02) |
| G18 | ZX plane selection | ZX plane selection (lathe standard) | Modal (02) |
| G19 | YZ plane selection | YZ plane selection (lathes with a Y axis and live tooling) | Modal (02) |
| G20 | Inch input | Inch input | Modal (06) |
| G21 | Metric (mm) input | Metric (mm) input | Modal (06) |
| G28 | Automatic return to reference point (zero return) | Automatic return to reference point (zero return) | One-shot (00) |
| G30 | 2nd (3rd, 4th) reference point return | 2nd (3rd, 4th) reference point return | One-shot (00) |
| G31 | Skip function (moves in a straight line until a signal comes in) | Skip function (moves in a straight line until a signal comes in) | One-shot (00) |
| G32 | — | Threading (feed for one pass) | Modal (01) |
| G40 | Cutter radius compensation cancel | Tool nose radius compensation cancel | Modal (07) |
| G41 | Cutter compensation left (tool is on the left of the direction of travel) | Tool nose radius compensation, left | Modal (07) |
| G42 | Cutter compensation right (tool is on the right of the direction of travel) | Tool nose radius compensation, right (used for typical OD turning toward –Z) | Modal (07) |
| G43 | Tool length compensation + (adds the offset) | (Not used on typical FANUC-type lathes. The tool offset is selected by the last 2 digits of the T code) | Modal (08) |
| G43.4 | Tool center point control (5-axis) | — | Modal |
| G44 | Tool length compensation – (subtracts the offset) | — | Modal (08) |
| G49 | Tool length compensation cancel | — | Modal (08) |
| G50 | Scaling cancel | Maximum spindle speed setting (also sets the coordinate system in system A) | Modal (11) |
| G52 | Local coordinate system setting | Local coordinate system setting | One-shot (00) |
| G53 | Machine coordinate system selection (positioning in machine coordinates) | Machine coordinate system selection (positioning in machine coordinates) | One-shot (00) |
| G54–G59 | Work coordinate systems 1–6 selection | Work coordinate systems 1–6 selection | Modal (14) |
| G61 | Exact stop mode | Exact stop mode | Modal (15) |
| G64 | Cutting mode (continuous cutting; cancels exact stop) | Cutting mode (continuous cutting; cancels exact stop) | Modal (15) |
| G65 | Macro call (simple call, with arguments) | Macro call (simple call, with arguments) | One-shot (00) |
| G66 | Modal macro call | Modal macro call | Modal (12) |
| G67 | Modal macro call cancel | Modal macro call cancel | Modal (12) |
| G68 | Coordinate rotation | Differs by machine (mirror of the opposed tool post, or coordinate rotation) | Modal (16) |
| G68.2 | Tilted working plane command (tilted coordinate system for 3+2 machining) | — | Modal |
| G69 | Coordinate rotation cancel | Differs by machine (mirror OFF of the opposed tool post, or coordinate rotation cancel) | Modal (16) |
| G70 | — | Finishing cycle (finishes the profile rough-cut with G71–G73) | One-shot (00) |
| G71 | — | OD/ID rough turning cycle (cuts along Z) | One-shot (00) |
| G72 | — | Face rough turning cycle (cuts along X) | One-shot (00) |
| G73 | High-speed peck drilling cycle (chip breaking, small retract) | Pattern repeating (closed-loop cutting) cycle (cuts following the stock shape, e.g. castings) | Modal (09) |
| G74 | Left-hand tapping cycle (reverse tapping) | End face grooving cycle / Z-direction deep hole peck drilling | Modal (09) |
| G75 | — | OD/ID grooving (cut-off) cycle | One-shot (00) |
| G76 | Fine boring cycle | Multiple thread cutting cycle (compound thread cutting cycle) | Modal (09) |
| G80 | Canned cycle cancel | Drilling canned cycle cancel (for live tooling, face drilling) | Modal (09) |
| G81 | Drilling cycle (spot drilling) | — | Modal (09) |
| G82 | Drilling cycle (counter boring, dwell at hole bottom) | — | Modal (09) |
| G83 | Deep hole drilling cycle (peck drilling, full retract to the R point each time) | End face deep hole drilling cycle (live tooling, lathe with C axis) | Modal (09) |
| G84 | Tapping cycle (right-hand thread) | Face tapping cycle (lathe with live tooling) | Modal (09) |
| G85 | Boring cycle (feed in, feed out) | Face boring (drilling) cycle (live tooling) | Modal (09) |
| G86 | Boring cycle (spindle stops at the hole bottom, rapid out) | — | Modal (09) |
| G87 | Back boring cycle (reverse spot facing) | Side deep hole drilling cycle (live tooling, systems A/B) | Modal (09) |
| G88 | Boring cycle (dwell at the hole bottom, spindle stop, manual retract) | Side tapping cycle (live tooling, systems A/B) | Modal (09) |
| G89 | Boring cycle (dwell at the hole bottom, feed out) | Side boring (drilling) cycle (live tooling) | Modal (09) |
| G90 | Absolute command | OD/ID cutting cycle (single canned cycle, G-code system A) | Modal (03) |
| G91 | Incremental command | (Not used in system A. Incremental values are written with U/W) | Modal (03) |
| G92 | Coordinate system setting (assigns coordinate values to the current position) | Thread cutting cycle (single canned cycle, G-code system A) | One-shot (00) |
| G94 | Feed per minute (mm/min) | Face cutting cycle (single canned cycle, G-code system A) | Modal (05) |
| G95 | Feed per revolution (mm/rev) | — | Modal (05) |
| G96 | Constant surface speed control | Constant surface speed control | Modal (13) |
| G97 | Constant surface speed control cancel (constant spindle speed) | Constant surface speed control cancel | Modal (13) |
| G98 | Canned cycle: return to initial point | Feed per minute (mm/min) (G-code system A) | Modal (10) |
| G99 | Canned cycle: return to R point | Feed per revolution (mm/rev) (G-code system A) | Modal (10) |
Yellow underline = the meaning differs between machining centers and lathes.
M codes
| Code | Meaning | Machine |
|---|---|---|
| M00 | Program stop | Machining center, Lathe |
| M01 | Optional stop (conditional stop) | Machining center, Lathe |
| M02 | Program end | Machining center, Lathe |
| M03 | Spindle on, clockwise (CW) | Machining center, Lathe |
| M04 | Spindle on, counterclockwise (CCW) | Machining center, Lathe |
| M05 | Spindle stop | Machining center, Lathe |
| M06 | Tool change (ATC) | Machining center |
| M07 | Mist coolant ON (number and meaning differ by machine) | Machining center, Lathe |
| M08 | Coolant (cutting fluid) ON | Machining center, Lathe |
| M09 | Coolant OFF | Machining center, Lathe |
| M19 | Spindle orientation (oriented spindle stop) | Machining center, Lathe |
| M29 | Rigid tapping (switches the spindle to position control) *machine-dependent* | Machining center, Lathe |
| M30 | Program end and rewind (end of tape) | Machining center, Lathe |
| M41–M44 | Switching the spindle gear (speed range) | Machining center, Lathe |
| M98 | Subprogram call | Machining center, Lathe |
| M99 | Subprogram end (return to the caller) | Machining center, Lathe |
Quick comparison between controls
How the same function is commanded on different controls. The “Machine” column shows whether the function is used on lathes, machining centers or both. Click a function to open its page.
| Function | Machine | FANUC-compatible (system A) | Mitsubishi Electric | Okuma OSP | Haas | Siemens (ISO dialect) | Siemens (native) | LinuxCNC |
|---|---|---|---|---|---|---|---|---|
| One threading pass | Lathe (mill-turn) | G32 F_ | G32 or G33 (differs by G-code list) | (not checked) | G32 F_ (Q is an integer) | G32 (system A), G33 (systems B and C) | G33 Z_ K_ | G33 Z_ K_ |
| Skip function (measurement) | Both | G31 | G31 | (not checked) | G31 (positions in #5061 onward) | G31 (positions in $AA_IM) | MEAS / MEAW | G38.2–G38.5 |
| Polar coordinate interpolation | Lathe (mill-turn) | G12.1 / G13.1 | G12.1 or G112 in lists 6 and 7 | (not checked) | Lathe G112/G113 | G12.1 / G13.1 | TRANSMIT | None |
| Cylindrical interpolation | Both | G07.1 | G07.1 or G107 in lists 6 and 7 | (not checked) | Machining center G107 | G07.1 | TRACYL | None |
| Tool center point control | 5-axis machining center | G43.4 (FANUC 30 series)One source / reference | G43.4 / G43.5One source / reference | G169CAM post output / reference | G234 | (not checked) | TRAORI | (not checked) |
| Tilted working plane | 5-axis machining center | G68.2+G53.1CAM post output / reference | Tilted working plane command (number not confirmed)One source / reference | (not checked) | G268 / G269 | (not checked) | CYCLE800 (swivel cycle) | (not checked) |
| Work coordinate system | Both | G54–G59 | G54–G59 | G15 H_CAM post output / reference | G54–G59, G110–G129, G154 P_ | G54–G59 | (not checked) | G54–G59.3One source / reference |
| Tool length compensation | Machining center | G43 H_ | G43 H_ | G56 H_ (cancel with G53)CAM post output / reference | G43 H_ | G43 H_ | (not checked) | G43 H_One source / reference |
| Subprogram | Both | M98 P_ (check the operator's manual for the number of digits) | M98 P_ H_ L_ | CALL O_ / RTSCAM post output / reference | M98 P_ L_, M97 | M98 P_ (L_) | Call by name (P is the repeat count) | M98 P_ L_, o-call |
| Spindle gear | Both | Defined by the machine builder (M41–M44 in the training material) | Automatic from S (up to 4 ranges) | (not checked) | M41 / M42 | M40–M45 (fixed meanings) | M40 automatic, M41–M45 | (not checked) |
| Mist | Both | Set by the machine builder | (not checked) | M07CAM post output / reference | M07 is shower coolant (not mist) | (not checked) | (not checked) | M7 |
“(not checked)” means it could not be confirmed in public documents in this research (not that the function does not exist). No public Okuma manual was found, so the Okuma column shows what a CAM maker’s (Autodesk) post processor outputs, marked “CAM post output / reference”. The “FANUC compatible” column was checked in the Siemens ISO dialect manual (which states FANUC compatibility), the MHLW training text and similar sources, not in FANUC’s own manuals. Many of these are options, so always check your machine’s manual.
Codes whose numbers clash (check before reusing a program)
The same or very similar numbers that do completely different things on different machines or controls. Before reusing a program from another builder’s machine or another CAM post, search it for the numbers in this table (use the button at the top right to print).
| Number | Meaning A | Meaning B | Details |
|---|---|---|---|
| G15, G16 | FANUC-compatible: cancel / ON of the polar coordinate command | Okuma OSP: G15 H_ selects the work coordinate system | G54–G59 |
| G56 | FANUC-compatible: work coordinate system 3 | Okuma OSP: tool length compensation (G56 H_) | G54–G59 G43 |
| G53 | FANUC-compatible: positioning in the machine coordinate system | Okuma OSP (CAM post-processor output): cancel tool length compensation | G53 G43 |
| G12, G13 | Haas machining centers: circular pocket milling | Differs from G12.1 and G13.1 (polar coordinate interpolation) only by the decimal point | G12.1–G13.1 |
| G12.1, G13.1 | Mitsubishi Electric lathes, lists 6 and 7: polar coordinate interpolation | Mitsubishi Electric lathes, lists 2–5: milling interpolation | G12.1–G13.1 |
| G112, G113 | Haas lathes and Mitsubishi Electric: polar coordinate interpolation | Haas machining centers: work coordinate systems #9 and #10 | G12.1–G13.1 |
| G7, G07.1 | G7 in LinuxCNC: lathe diameter mode | G07.1: cylindrical interpolation | G07.1 |
| G32, G33 | G-code system A: G32 is threading | Systems B and C, Siemens native, LinuxCNC: G33 is threading | G32 |
| M43, M44 | Spindle gear ranges 3 and 4 (MHLW training material, etc.) | Haas lathes: turret unclamp / clamp | M41–M44 |
| M40 | Siemens: automatic gear selection | Beckhoff: gear range 1 | M41–M44 |
| M07 | Mist (LinuxCNC, NIST language specification) | Haas machining centers: shower coolant | M07 M08 |
| P of M98 | ISO dialect: program number (the upper digits are the repeat count) | Siemens native: P is the repeat count | M98 |
| G68, G68.2 | G68: 2D coordinate rotation within the machining plane | G68.2: coordinate system on a tilted plane in space (3+2 machining) | G68 G68.2 |
The decimal point is read differently too: X1000 can mean 1000 mm or 1 mm. See the decimal point page
Frequently Asked Questions
- What are the main M codes on FANUC-type controls?
- In the common FANUC-type assignments, frequently used codes are M00 program stop, M01 optional stop, M02/M30 program end, M03/M04 spindle forward/reverse, M05 spindle stop, M06 tool change, M08/M09 coolant on/off, and M98/M99 subprogram call/end. Assignments differ by machine builder and model (M19, M29 and others), so your machine’s manual takes priority over the table above.
- Do G90, G94, G98 and G99 mean different things on machining centers and lathes?
- Yes. On a machining center, G90 is absolute programming, G94 is feed per minute and G98/G99 are initial-point and R-point return in canned cycles. On a lathe (G-code system A), G90 and G94 are the OD/ID and face cutting cycles, and G98/G99 are feed per minute and feed per revolution. G50 also becomes the maximum spindle speed setting on a lathe.
- Do M codes mean different things on different machines?
- They can. M codes are assigned by the machine builder, so the same number can mean different things on different machines. For example, M07 is mist in LinuxCNC and the NIST language specification, but shower coolant on Haas machining centers. Always check a real program against your machine’s manual.
- What should I watch for when reusing a program from another builder’s machine?
- Search it for codes whose numbers clash. For example, G56 is work coordinate system 3 on FANUC-compatible controls but tool length offset (G56 H_) on Okuma OSP. Numbers without a decimal point (X1000) can also mean 1000 mm or 1 mm depending on the machine’s setting.