Skip to content

Preparatory codes · 116 codes

G-codes

G-codes tell the machine how to move: rapid or cutting, straight line or arc, in which plane, with which work offset and which compensation. Here are the most used ones and the full lathe and mill list, each with its own reference page.

The most used G-codes

Most milling and turning programs are written with these. Open any of them to see the syntax per control and an example.

Full G-code list

Sorted by number. Each code links to its page with the syntax per control, an example and common mistakes.

Full G-code list
CodeWhat it doesMachine
G00Quick positioningMill, Lathe, Mill-turn
G01Linear interpolationMill, Lathe, Mill-turn, Laser
G02Hourly circular interpolationMill, Lathe, Mill-turn
G02.1/G03.1Spiral interpolation (circular threading B)Mill, Lathe, Mill-turn
G02.2/G03.2Involute interpolationMill, Mill-turn
Mitsubishi G02.3/G03.3Exponential interpolationMill, Mill-turn
G03Counterclockwise circular interpolationMill, Lathe, Mill-turn
G04Timed dwellMill, Lathe, Mill-turn
G05/G05.1High speed / AI contourMill, Mill-turn
G5/G5.1/G5.2Splines and NURBSMill, Mill-turn
G05.4HRV3/HRV4 on/offMill, Mill-turn
G06.2NURBS interpolationMill, Mill-turn
G07Hypothetical axis interpolationMill, Lathe, Mill-turn
G7/G8Diameter/radius mode around latheLathe, Mill-turn
Mitsubishi G07.1/G107Cylindrical interpolationMill, Lathe, Mill-turn
G08/G09Smoothing and block-wise exact stopMill, Lathe, Mill-turn
G10Offset writingMill, Lathe, Mill-turn
Mitsubishi G10/G11Programmable data inputMill, Lathe, Mill-turn
Fanuc G10.6/G10.8/G10.9Retraction, internal data and diameter/radiusMill, Lathe, Mill-turn
G12/G13Circular pocketMill, Mill-turn
Fanuc G12.1/G13.1Lathe polar interpolationLathe, Mill-turn
Mitsubishi G12.1/G13.1Polar interpolationLathe, Mill-turn
Haas G14/G15Lathe subspindle transferLathe, Mill-turn
G15/G16Polar coordinatesMill, Mill-turn
Okuma G15 HOkuma offset selectionMill, Mill-turn
G17/G18/G19Plane selectionMill, Lathe, Mill-turn
G20/G21Units inches/millimetersMill, Lathe, Mill-turn
G22/G23Programmed stroke limitsMill, Lathe, Mill-turn
G25/G26Spindle speed fluctuation detectionMill, Lathe, Mill-turn
G27Reference return checkMill, Lathe, Mill-turn
G28/G30Return to referenceMill, Lathe, Mill-turn
Fanuc G29/G30.1/G30.2Advanced reference returnsMill, Lathe, Mill-turn
G31Skip / probingMill, Lathe, Mill-turn
G32Simple lathe threadingLathe, Mill-turn
G33/G33.1Synchronized tappingLathe, Mill-turn
G34Variable-lead threadingLathe, Mill-turn
Haas G35/G36/G37Haas automatic measurement toolMill, Mill-turn
G36/G37Automatic tool measurementLathe, Mill-turn
G38.2-G38.5Advanced straight probingMill, Lathe, Mill-turn
G39Corner interpolation with offsetMill, Lathe, Mill-turn
G40/G41/G42Radius compensationMill, Lathe, Mill-turn
G41.1/G42.1Dynamic radius compensationMill, Mill-turn
G41.2/G42.23D tool radius compensation (5 axes)Mill, Mill-turn
G43/G49Length compensationMill, Mill-turn
G43.4/G43.5TCP/5-axis compensationMill, Mill-turn
G44Positive length compensationMill, Mill-turn
G45-G48Offset increment/decrementMill, Lathe, Mill-turn
Haas G47Text engravingMill, Lathe, Mill-turn
G50Lathe RPM limiterLathe, Mill-turn
G50.1/G51.1Programmable mirroringMill, Mill-turn
Fanuc G50.2/G51.2Polygon turningLathe, Mill-turn
Fanuc G50.3/G54.2Dynamic part and fixture presetMill, Lathe, Mill-turn
Fanuc G50.4-G51.6Synchronous, composite and overlapping controlLathe, Mill-turn
G51/G50Scale/scale cancellationMill, Mill-turn
G52/G92Local shift / presetMill, Lathe, Mill-turn
G53Movement in machine coordinatesMill, Lathe, Mill-turn
G54-G59Part zeroMill, Lathe, Mill-turn
G54.1Extended offsetsMill, Lathe, Mill-turn
G54.4WSEC part position error compensationMill, Mill-turn
G60Single-direction positioningMill, Lathe, Mill-turn
G61/G64Exact stop and continuous modeMill, Lathe, Mill-turn
G62/G63Automatic override/threading modeMill, Lathe, Mill-turn
G65Macro callMill, Lathe, Mill-turn
G66/G67Modal macro and cancellationMill, Lathe, Mill-turn
G66.1Modal macro B callMill, Lathe, Mill-turn
G68/G69Coordinate rotationMill, Mill-turn
Fanuc G68.3/G68.4Advanced inclined planeMill, Mill-turn
G70/G71/G72/G73Lathe roughing and finishing familyLathe, Mill-turn
Haas G70/G71/G72 millHaas hole patternsMill, Mill-turn
G71Lathe roughing cycleLathe, Mill-turn
Okuma G71/G73/G75-G78Okuma lathe cyclesLathe, Mill-turn
Fanuc G71.7-G76.7Modern .7 lathe cyclesLathe, Mill-turn
Fanuc G72.1/G72.2Pattern repeatMill, Mill-turn
G73Fast pecking drillingMill, Mill-turn
G74 fresadoReverse tapping / special milling cycleMill, Mill-turn
G74/G75Deep drilling and grooving on the latheLathe, Mill-turn
G76Lathe threading cycleLathe, Mill-turn
Haas G77Back bore / flatting cycleMill, Lathe, Mill-turn
G80Cancel fixed cycleMill, Mill-turn
Fagor G81-G89Fagor drilling and tappingMill, Mill-turn
G81/G82/G83Drilling canned cyclesMill, Mill-turn
G83.1Peck drilling high speedMill, Mill-turn
G84Rigid threading on a milling machineMill, Mill-turn
G84.2/G84.3Rigid threading format FS15 / leftMill, Mill-turn
G85-G89Boring, reaming and hole cyclesMill, Mill-turn
G86/G87/G88Special boring cyclesMill, Mill-turn
G90 tornoSimple turning/taper cycleLathe, Mill-turn
G90/G91Absolute / incrementalMill, Lathe, Mill-turn
G90.1/G91.1IJK absolute/incremental modeMill, Lathe, Mill-turn
G92 tornoSimple lathe threading cycleLathe, Mill-turn
G92.1/G92.2Cancel/suspend offset G92Mill, Lathe, Mill-turn
G93Inverse time feedMill, Mill-turn
G94 tornoSimple facing cycleLathe, Mill-turn
G94/G95Advance modeLathe, Mill, Mill-turn
G96/G97Constant speed / fixed RPMLathe, Mill-turn
G98/G99Return plane in canned cyclesMill, Lathe, Mill-turn
Haas G100/G101Haas mirror imageMill, Mill-turn
Haas G102Programmable RS-232 outputMill, Mill-turn
Haas G103Limit look-aheadMill, Lathe, Mill-turn
Haas G105Servo bar commandLathe, Mill-turn
Haas G107Cylindrical mappingMill, Mill-turn
Okuma G107OSP cylindrical interpolationLathe, Mill-turn
Haas G110-G129Legacy Haas extended offsetsMill, Mill-turn
Haas G112/G113XY to XC for live toolLathe, Mill-turn
Haas G136Automatic center of origin measurementMill, Mill-turn
Haas G1413D+ tool compensationMill, Mill-turn
Haas G1435-axis length compensationMill, Mill-turn
Haas G150General pocket via subprogramMill, Mill-turn
Haas G153-G169Haas 5-axis canned cyclesMill, Mill-turn
Haas G154Extended offsets P1-P99Mill, Lathe, Mill-turn
Haas G156/G167Broaching and setting modificationMill, Mill-turn
Haas G170/G171/G172Override radius/diameter latheLathe, Mill-turn
Haas G174/G184Rigid non-vertical threadingMill, Mill-turn
Haas G186Automatic door opening/closingMill, Lathe, Mill-turn
Haas G187Haas Smoothing/Precision ControlMill, Mill-turn
Siemens G505-G599Siemens extended offsetsMill, Lathe, Mill-turn

01Modal and non-modal: why a G-code stays active

Almost all G-codes are modal: once written they stay active in the following blocks until another code from the same group replaces them. That is why after G01 you only need coordinates: the machine keeps cutting in a straight line. Non-modal codes only act in their own block, such as the G04 dwell, the G28 reference return or the G53 machine-coordinate move.

02Groups: only one per group at a time

G-codes are organised in groups and only one per group can be active: motion (G00, G01, G02, G03), plane (G17, G18, G19), absolute or incremental (G90, G91), units (G20, G21), cutter radius compensation (G40, G41, G42), tool length compensation (G43, G49), canned cycles (G73 to G89, cancelled with G80) and work offsets (G54 to G59). Writing two from the same group in one block is a classic mistake: the control keeps the last one or raises an alarm.

03Lathe and mill do not always mean the same

The same number can do different things depending on the machine. On a Fanuc lathe G71 is the roughing cycle, while on other controls G71 selects millimetres; on a lathe G50 limits rpm or sets coordinates and G90 can be a turning cycle; G96 and G97 (constant surface speed or fixed rpm) are almost lathe-only. Before copying a program between machines, check the control and the G-code system it uses.

04Every control adds its own

The ISO base is shared, but Fanuc, Haas, Siemens, Heidenhain, Fagor, Okuma and Mitsubishi add their own codes: pocket cycles, high-speed machining, 5-axis or probing. The list below also includes the manufacturer-specific G-codes we document, with the brand in front.

Frequently asked questions

What is a G-code?

It is a preparatory command in a CNC program: it sets the type of motion (rapid, linear, circular), the working plane, units, work offset, compensations or the canned cycle the machine will use in the following blocks.

What is the difference between G-codes and M-codes?

G-codes prepare and control tool motion; M-codes control auxiliary machine functions such as the spindle (M03, M05), coolant (M08, M09), tool change (M06) or end of program (M30).

Are G-codes the same on every machine?

The basic ones (G00, G01, G02, G03, G17, G54, G90…) are almost universal, but many change between lathe and mill and between controls. Always check your control manual before running a new program.

What is the difference between G00 and G01?

G00 moves in rapid to position, without cutting and without a programmed feed; G01 moves in a straight line cutting at feed F. Using G00 close to the part is one of the most common causes of crashes.

General reference: syntax and meaning change with the control, the machine builder and machine parameters. Check the official manual before running a program. Last updated: