This website requires JavaScript.
Coupons
Blog

CNC G Code List: Functions and Common Uses

Published Oct 31, 2026, updated Oct 31, 2026

22 min

Table of Contents
  • CNC G Code List and Their Functions
  • How Do Modal and Non-Modal G Codes Work?
  • Example of G Codes in a CNC Program
  • How to Verify G Code Compatibility Before Running a CNC Program
  • FAQs About CNC G Codes

Key Takeaways

  • G codes control CNC motion modes and machining functions, including rapid positioning, linear and circular interpolation, canned cycles, coordinate selection, and tool compensation. Feed rate values are typically specified with the F address, while G codes such as G94 and G95 select how the feed rate is interpreted.
  • Modal G codes stay active once programmed until cancelled by another code in the same group. Non-modal G codes apply only to the block where they appear.
  • Codes such as G00, G01, and G02 have broadly consistent motion functions across common CNC controls. Coordinate modes and canned cycles require closer attention because their definitions can differ between milling and turning systems.
  • Always verify G codes against the specific machine and controller documentation before running a program.
Example of sequence number, G code, X-axis address and value, and feed rate

Example of sequence number, G code, X-axis address and value, and feed rate

G codes are commands in CNC programs that specify motion modes and machining functions. Depending on the code and controller, they can control rapid positioning, linear or circular interpolation, canned cycles, coordinate modes, and tool compensation.

Even when CAM software generates the program, engineers and operators still need to inspect the output for unexpected motion or post-processor errors before machining begins.

For an overview of how G codes and M codes work together in CNC programming, see the G and M codes guide.

CNC G Code List and Their Functions

This CNC G code list brings commonly used commands and selected machine-specific codes into one numerical reference table. When a code has different meanings on milling and turning machines, the table lists those uses separately and identifies the relevant controller or machine type.

The descriptions cover common programming conventions rather than a universal code standard. Modal group assignments, address formats, cycle parameters, and execution behavior can vary by controller. Check the programming manual for the target machine before using a code in a production program.

Note

This is a reference for commonly used G codes and selected controller-specific examples, not an exhaustive list of every code supported by every CNC machine. Codes that share a number may have different functions across machine types or control families. Verify the exact definition, syntax, prerequisites, and cancellation behavior in the target machine's programming manual before running a program.

G Code Function Controller / Machine Notes
G00Rapid positioningCommon on many CNC controlsMoves axes to a programmed position at rapid traverse rates. The resulting path may not be a straight line, so check clearance before using rapid motion near the workpiece.
G01Linear interpolationCommon on many CNC controlsMoves along a straight-line path at the programmed feed rate. The F value and feed interpretation depend on the active feed mode.
G02Clockwise circular interpolationCommon on many CNC controlsProduces a clockwise arc in the selected plane. Arc definition commonly uses I/J/K center offsets or an R value, depending on the control and programming format.
G03Counterclockwise circular interpolationCommon on many CNC controlsProduces a counterclockwise arc in the selected plane. The active plane determines which axes define the arc.
G04DwellCommon on many CNC controlsPauses execution for a specified time. The dwell address and time units depend on the controller.
G05Controller-specific high-speed or precision machining functionSelected controllersG05 has different definitions across controller families. Check the target control's programming manual for its exact function and supported syntax before use.
G05.1Advanced preview controlSelected FANUC controlsUsed for specific high-speed machining functions on supported FANUC controls. The required syntax and options depend on the control series.
G09Exact stop checkSelected controllersRequires the machine to reach the programmed position before continuing. This is generally a one-block command; confirm implementation on the target control.
G10Programmable data inputSelected controllersCan write work offsets or other CNC data through program commands. Address formats and supported data types are controller-specific.
G12Clockwise circular pocket millingSelected Haas controlsUsed for a circular pocket-milling cycle on supported controls. Do not treat it as a universal G code.
G12.1Polar coordinate interpolationSelected turning controlsEnables polar interpolation on supported turning systems. It is distinct from the G12 circular pocket cycle used on some milling controls.
G13Counterclockwise circular pocket millingSelected Haas controlsUsed for a counterclockwise circular pocket-milling cycle on supported controls.
G15Cancel polar coordinate modeSelected FANUC controlsCancels the polar coordinate mode established by the corresponding supported command. Confirm the control-specific syntax.
G16Polar coordinate modeSelected FANUC controlsAllows positions to be programmed using polar coordinates on supported controls. Availability and address conventions vary.
G17XY plane selectionCommon on many milling controlsSelects the XY plane for applicable arc and cycle operations.
G18XZ plane selectionCommon on many CNC controlsSelects the XZ plane for applicable arc and cycle operations. It is commonly used for turning operations.
G19YZ plane selectionCommon on many milling controlsSelects the YZ plane for applicable arc and cycle operations.
G20Inch inputCommon on many CNC controlsInterprets applicable programmed linear values in inches. Confirm the expected units before running the program.
G21Metric inputCommon on many CNC controlsInterprets applicable programmed linear values in millimeters.
G27Reference position return checkSelected controllersChecks whether the machine reaches its reference position as specified by the control. Exact behavior and supported axes vary.
G28Return to reference positionCommon on many CNC controlsReturns an axis to a machine reference position, often through an intermediate point. Review the programmed path and the controller's reference-return behavior before execution.
G29Return from reference positionSelected controllersUsed on supported controls to move from a reference-return position toward a programmed point, often using a point associated with G28. Exact behavior varies.
G30Return to a secondary reference positionSelected controllersMoves to a second or other configured reference position where supported. The available positions and selection method depend on the control.
G31Skip-function moveSelected controllersExecutes a move that can stop when a skip signal is received. Used in supported probing or measurement routines; signal handling and syntax are control-specific.
G32Thread cuttingCNC turning controlsProduces a spindle-synchronized threading move on supported turning controls. It is typically used for single-pass threading rather than a complete multi-pass cycle.
G40Cancel cutter or tool-nose-radius compensationMilling and turning controlsCancels the applicable compensation mode. The required cancellation move and safe lead-out depend on the control and operation.
G41Cutter radius compensation leftMilling controlsOffsets the tool path to the left of the programmed contour when viewed in the direction of travel. The controller must have a valid cutter-radius offset, and the lead-in move must provide sufficient distance to establish compensation.
G41Tool-nose-radius compensation leftTurning controlsApplies the supported left-side tool-nose-radius compensation. The insert orientation and programmed contour affect the result.
G42Cutter radius compensation rightMilling controlsOffsets the tool path to the right of the programmed contour when viewed in the direction of travel. The controller must have a valid cutter-radius offset, and the lead-in move must provide sufficient distance to establish compensation.
G42Tool-nose-radius compensation rightTurning controlsApplies the supported right-side tool-nose-radius compensation for turning operations.
G43Positive tool length compensationSelected milling controlsApplies the tool length offset, commonly selected with an H address. Confirm the control's compensation direction and activation requirements.
G43.1Dynamic tool length compensationSelected controlsSupports a form of dynamic tool length compensation on certain controls. The exact function and syntax are controller-specific.
G43.2Additional tool length compensationSelected controlsSupports an additional tool length offset on certain controls. Confirm whether the control and machine configuration support it.
G43.4Tool center point controlSelected multi-axis controlsUsed for tool center point control on supported machines. Activation requirements and behavior depend on the control and machine configuration.
G43.5Tool center point control (selected FANUC controls)Selected controlsUsed for tool center point control on supported FANUC configurations. Confirm the control series, required options, and programming syntax in the applicable manual.
G44Negative tool length compensationSelected controlsApplies negative tool length compensation where supported. It is not used in the same way on every controller.
G49Cancel tool length compensationSelected milling controlsCancels the active tool length compensation mode. Confirm the safe sequence for retracting and changing tools on the target machine.
G50Set maximum spindle speedSelected turning controlsOften sets the upper spindle-speed limit used with constant surface speed. The address and behavior depend on the turning control.
G50Scaling cancellation or coordinate-related functionSelected milling controlsSome controls assign G50 a different function. Do not transfer the turning definition to a milling machine without checking its manual.
G51ScalingSelected controllersApplies coordinate scaling on controls that support it. Scaling factors, center points, and cancellation behavior vary.
G52Local coordinate offsetSelected controllersApplies a local coordinate shift where supported. Do not assume that a fixed cancellation block works on every control; verify the offset behavior and reset method.
G53Machine coordinate moveSelected controllersExecutes a move in machine coordinates on supported controls. On many common controls, G53 applies only to the block in which it appears. Check the required motion command and any restrictions in the target controller's manual.
G54Work coordinate system 1Common on many CNC controlsSelects the first standard work offset. Its stored origin determines the relationship between programmed coordinates and the workpiece.
G55Work coordinate system 2Common on many CNC controlsSelects the second standard work offset.
G56Work coordinate system 3Common on many CNC controlsSelects the third standard work offset.
G57Work coordinate system 4Common on many CNC controlsSelects the fourth standard work offset.
G58Work coordinate system 5Common on many CNC controlsSelects the fifth standard work offset.
G59Work coordinate system 6Common on many CNC controlsSelects the sixth standard work offset. Some controls support additional work offsets through extended syntax.
G54.1Extended work coordinate systemsSelected FANUC and compatible controlsSelects an extended work offset using controller-specific syntax, often with a P address. The number of available offsets depends on the control.
G61Exact stop modeSelected controllersSelects exact-stop path control where supported. This can affect corner behavior and machining time.
G64Continuous-path modeSelected controllersSelects a continuous-path or blending mode on supported controls. The controller may smooth transitions to maintain motion, subject to its settings.
G68Coordinate rotationSelected milling controlsRotates the programmed coordinate system on supported controls. The rotation center, angle format, and cancellation method vary.
G68.2Tilted working planeSelected multi-axis controlsDefines a tilted working plane on supported controls. The required angles and subsequent coordinate behavior are controller-specific.
G69Cancel coordinate rotationSelected controllersCancels a coordinate rotation mode where supported. Confirm whether other coordinate transformations remain active.
G70Finishing cycleFANUC turning controlsExecutes a finishing cycle over a previously defined contour on supported FANUC turning controls. The contour format and cycle parameters depend on the control series.
G71Rough turning cycleFANUC turning controlsExecutes a rough-turning cycle using a defined contour and control-specific parameters. The block format differs by control series.
G72Rough facing cycleFANUC turning controlsExecutes a rough-facing cycle on supported turning controls.
G73Pattern-repeating cycleSelected turning controlsRepeats a previously defined contour under the cycle's programmed conditions. The exact syntax depends on the control.
G73High-speed peck drilling cycleSelected milling controlsPerforms a peck-drilling cycle with a short retract or chip-break motion on supported controls. Its retract behavior differs from G83.
G74Face-grooving or pecking cycleSelected turning controlsUsed for supported turning operations such as face grooving or pecking. The cycle definition depends on the controller.
G74Left-hand tapping cycleSelected milling controlsUsed for left-hand tapping on certain milling controls. Confirm spindle direction, tapping synchronization, and cycle syntax.
G75OD/ID grooving cycleSelected turning controlsExecutes a grooving cycle on supported turning controls. The cycle typically uses repeated cutting moves; parameter formats vary.
G76Multi-pass threading cycleCNC turning controlsAutomates multiple threading passes on supported turning controls. Threading parameters and block formats depend on the control.
G76Fine boring cycleSelected milling controlsPerforms a fine-boring cycle on controls that assign this function to G76. Spindle orientation and retract behavior depend on the machine.
G80Cancel canned cycleCommon on many milling controlsCancels an active canned cycle where supported. Use it before subsequent motion that should not repeat the drilling or boring cycle.
G81Drilling cycleCommon on many milling controlsFeeds to the programmed drilling depth and retracts according to the active cycle parameters.
G82Drilling cycle with dwellSelected milling controlsAdds a dwell at the bottom of the hole on supported controls. It is often used for spot drilling or operations requiring a dwell; it is not universally a counterboring cycle.
G83Peck drilling cycleCommon on many milling controlsDrills in increments with retracts for chip clearance. The retract method and peck parameters depend on the control.
G84Tapping cycleCommon on many milling controlsPerforms a tapping cycle on supported controls. Rigid-tapping requirements, spindle synchronization, and return behavior must be checked.
G85Boring cycle, feed in and feed outSelected milling controlsFeeds into the bore and retracts at a programmed feed rate. Do not treat it as a universal reaming cycle.
G86Boring cycle with spindle stopSelected milling controlsStops the spindle at the programmed depth before retracting on supported controls. Confirm the retract method for the target machine.
G87Back-boring cycleSelected milling controlsSupports back-boring operations on controls that implement the cycle. Tool orientation and shifting requirements depend on the machine.
G88Boring cycle with manual retractSelected milling controlsUses a manual-retract sequence on supported controls. Operator interaction and spindle behavior depend on the control.
G89Boring cycle with dwellSelected milling controlsAdds a dwell at the programmed depth before feed retract on supported controls.
G90Absolute coordinate modeCommon on many milling controlsInterprets programmed positions relative to the active coordinate origin. On some turning controls, G90 instead identifies a turning cycle.
G90Turning cycleSelected turning controlsDefines a turning cycle on some controls. Do not assume it means absolute positioning on every lathe.
G91Incremental coordinate modeCommon on many milling controlsInterprets programmed positions as increments from the current position. Confirm how the controller handles each axis and any mixed absolute/incremental address formats.
G93Inverse-time feed modeSelected controllersUses inverse-time feed programming. The F value represents an inverse-time feed specification according to the controller's rules; it should not be described universally as "blocks per minute."
G94Feed per minuteCommon on many milling controlsInterprets the programmed feed rate as distance per minute, such as mm/min or in/min.
G95Feed per revolutionSelected controlsInterprets feed as distance per spindle revolution where supported. Check the control's feed-mode assignments, especially on turning centers.
G96Constant surface speedCNC turning controlsAdjusts spindle speed to maintain the programmed surface speed as the workpiece diameter changes. Set an appropriate maximum RPM limit where required by the control.
G97Cancel constant surface speed / fixed-RPM modeSelected turning controlsOn supported turning controls, G97 cancels constant surface speed and returns spindle-speed programming to RPM mode. Do not assume that G97 is supported or has the same meaning on a milling controller.
G98Initial-plane return for canned cyclesSelected milling controlsReturns to the initial Z plane after a canned cycle on controls using this convention.
G98Feed per minuteSelected turning controlsSome turning controls use G98 to select feed per minute. Verify the control-specific definition rather than applying the milling meaning.
G99R-plane return for canned cyclesSelected milling controlsReturns to the R plane after a canned cycle on controls using this convention.
G99Feed per revolutionSelected turning controlsSome turning controls use G99 to select feed per revolution. Its meaning differs from the milling canned-cycle return mode.

How Do Modal and Non-Modal G Codes Work?

Modal G codes are the most important concept to understand when reading or writing CNC programs. A modal G code stays active after the block where it's programmed. It continues to apply to every subsequent block until a code from the same modal group replaces or cancels it. The CNC controller does not need the code repeated in every block because the mode remains active until it is replaced or cancelled.

Take G01 as an example. Once you program G01 in a block, every subsequent motion block executes as a linear feed move, even if G01 isn't written again. The mode is active until G00, G02, G03, or another Group 1 code appears. This allows consecutive cutting blocks to omit the motion code when the same mode remains active. The controller continues to apply the previously established G01 mode until another code in the same modal group replaces it.

Non-modal G codes apply to the block in which they are programmed rather than remaining active across subsequent blocks. G04 (dwell), for example, pauses execution for the specified time and does not carry the dwell into the next block. G28 and G53 also operate as single-block commands on many common controls, although their exact behavior must be checked against the target controller's documentation.

A program should not rely on the controller's previous modal state. If a program assumes G90 is active but the controller is still in G91, programmed positions may be interpreted incrementally rather than from the active coordinate origin. The resulting motion can differ substantially from the intended toolpath. Explicitly establish the required modes at the start of the program, following the machine builder's programming conventions.

This is why experienced programmers include a safety initialization block at the beginning of every program:

N010 G21 G17 G40 G49 G80 G90 G94

On many milling controls, this block establishes the metric unit system, XY plane, cancelled cutter and tool length compensation, cancelled canned cycle, absolute positioning, and feed-per-minute mode. Adapt the initialization block to the target controller and machine, and explicitly set any additional modes required by the operation.

Modal groups also matter for post-processor configuration. The group assignment for a specific G code determines which other codes it cancels. Modal group assignments determine which active modes are replaced when a new G code is programmed. Do not assume that a code belongs to the same group across different controller families; check the programming manual when configuring a post-processor or troubleshooting unexpected modal behavior.

Example of G Codes in a CNC Program

The following FANUC-style example illustrates a rectangular contour-milling pass on a vertical machining center. It demonstrates coordinate modes, tool length compensation, cutter radius compensation, and a reference return. It does not clear the interior of a pocket. The code is illustrative; verify the syntax, offsets, toolpath, and safe clearances for the target machine and controller before running it.

O3001                              ; Program number
N010 G21 G17 G40 G49 G80 G90 G94
                                   ; Metric units, XY plane, cancel compensation
                                   ; and canned cycles, absolute mode, feed per minute
N020 G28 G91 Z0                    ; Return Z to the machine reference position
N030 G90 G54                       ; Restore absolute mode and select work offset G54
N040 T01 M06                       ; Tool change: tool 1
N050 S5000 M03                     ; Set spindle speed to 5000 RPM and start clockwise
N060 G00 G43 H01 Z50.0             ; Apply tool length offset H01 and move to Z50
N070 G00 X10.0 Y10.0               ; Rapid to the programmed XY position
N080 G00 Z2.0                      ; Rapid to the approach plane
N090 G01 Z-5.0 F200                ; Feed to the programmed depth
N100 G01 G41 D01 X15.0 F200        ; Activate cutter compensation on the lead-in move
N110 G01 Y40.0 F400                ; Mill the first side
N120 X65.0                         ; Mill the second side
N130 Y10.0                         ; Mill the third side
N140 X15.0                         ; Mill the fourth side
N150 G40 X10.0 Y10.0               ; Cancel cutter compensation during lead-out
N160 G00 Z50.0                     ; Retract to the programmed clearance position
N170 G49                           ; Cancel tool length compensation
N180 G28 G91 Z0                    ; Return Z to the machine reference position
N190 G90                           ; Restore absolute positioning
N200 M30                           ; End program and rewind

How to read the program

Coordinate and motion modes: G21 selects metric input, G54 selects the work coordinate system, G90 selects absolute positioning, and G94 selects feed per minute. G28 commands a return to the machine reference position. In this example, G91 Z0 specifies a zero incremental Z move before the reference-return sequence.

Tool length compensation: G43 H01 applies the configured tool length offset during the move to the programmed Z position. Z50.0 is expressed in the active work coordinate system, with the controller applying the active compensation according to its rules.

Cutter radius compensation: G41 activates left cutter compensation using the configured D01 offset. G40 cancels compensation during the exit move. The lead-in and lead-out distances must be checked against the cutter diameter, compensation value, contour geometry, and controller requirements.

Feed and spindle commands: S5000 M03 sets the spindle speed to 5000 RPM and starts clockwise rotation. F200 and F400 specify feed rates in the active G94 mode, normally interpreted as mm/min under G21.

This example shows a single contour pass, not a complete pocketing strategy. The cutter compensation moves are illustrative. Their suitability depends on the actual cutter diameter, D01 offset, contour geometry, and controller requirements. Validate the toolpath and clearance positions through simulation and at the machine before running the program.

JLCCNC Logo

Precision CNC Machining Service

Preparing a part for CNC machining? Upload your CAD file to JLCCNC for a project-specific engineering review, with quotes starting from $1 and lead times as short as 3 days.

Get Instant Quote

How to Verify G Code Compatibility Before Running a CNC Program

  1. Check the machine builder's programming manual. The manual lists every G code the machine implements, which modal group it belongs to, its parameters, prerequisites, and any machine-specific behavior. Machine builders and controller manufacturers may provide programming manuals for their products. Use the documentation for the exact machine and control series rather than relying on a generic G code reference.
  2. Check the controller documentation separately from the machine manual. The machine builder and the controller manufacturer are sometimes different. A machine may use a Fanuc 0i-MF controller with machine-builder additions layered on top. The Fanuc programming manual covers the controller-level G codes. The machine builder's manual covers machine-specific additions and any modifications to standard behavior.
  3. Verify the CAM post-processor matches the machine and controller. The post-processor translates CAM toolpaths into G code for a specific machine and controller. A generic post-processor may produce code that is syntactically plausible but incompatible with the target machine, such as an unsupported cycle format or a missing required address. The post-processor should be specific to the machine model and controller version. Run a test program from the post-processor and compare the output against the machine manual's cycle syntax before committing to production use.
  4. Simulate the program before running. CAM simulation shows the toolpath geometrically but doesn't interpret the G code the way the controller does. NC verification software such as VERICUT, simulates the program as the specific controller will read it, including modal state behavior, work offset application, cutter comp logic, and canned cycle execution. This step catches post-processor errors and code-level problems that visual CAM simulation misses.
  5. Dry run at the machine. Before the first production run, run the program at the machine with the spindle off, rapid override at 10-20%, and feed override ready to zero. Watch each move and verify that the programmed positions, approach distances, and cycle depths match the intended setup. Investigate any unexpected motion before machining the workpiece. Any motion that looks wrong, a Z approach that comes closer to the part than expected, an arc that goes the wrong direction, should be investigated before material is loaded.

FAQs About CNC G Codes

Q: What Is the Difference Between G00 and G01?

G00 commands rapid positioning, with the resulting axis path depending on the controller's motion behavior. G01 commands linear interpolation at the programmed feed rate, using the active feed mode.

Q: What Is the Difference Between G02 and G03?

G02 moves the tool clockwise in an arc, while G03 moves it counterclockwise.

Q: What Is the Difference Between G90 and G91?

On controls that use G90 and G91 for coordinate modes, G90 selects absolute positioning relative to the active coordinate origin, while G91 selects incremental positioning relative to the current position. Some turning controls assign G90 a different function, so check the machine's programming manual.

Q: Are G Codes the Same on All CNC Machines?

No. Common codes like G00 and G01 work on most CNC machines, but other codes and their settings can vary by controller. Always check the machine's programming manual.

Keep Learning