Discrete ManufacturingFree referencePDF, Excel, Word exportMachine Shops

CNC G-Code Reference Table

A G-code lookup is one of the most searched machining references. This table lists the codes used daily on mills and lathes with a plain-language function and the traps that usually catch people.

Download:
G-codeFunctionGroupMill / LatheNotes
G00
Rapid positioning
Motion
Both
Non-cutting move at maximum traverse. Check the path for clamps and the part.
G01
Linear interpolation
Motion
Both
Straight cutting move at the programmed F feed.
G02
Circular interpolation clockwise
Motion
Both
Use I, J, K center offsets or an R radius.
G03
Circular interpolation counterclockwise
Motion
Both
Same address words as G02.
G04
Dwell
Non-modal
Both
Pause using P (milliseconds on many controls) or X (seconds). Check your control.
G09
Exact stop, single block
Non-modal
Both
Decelerates to exact position at the end of the block.
G10
Programmable data input
Non-modal
Both
Writes work or tool offsets from the program.
G17
XY plane selection
Plane
Mill
Default plane for arcs and cutter compensation on most mills.
G18
ZX plane selection
Plane
Both
Default plane on a lathe.
G19
YZ plane selection
Plane
Mill
For arcs in the YZ plane.
G20
Inch units
Units
Both
Fanuc-style. Some controls use G70 for inch.
G21
Metric units
Units
Both
Fanuc-style. Some controls use G71 for metric.
G28
Return to machine home via intermediate point
Non-modal
Both
Usually used with G91 for a safe move to zero return.
G30
Return to second reference point
Non-modal
Both
Commonly used for tool change position.
G40
Cutter radius compensation cancel
Compensation
Mill
Cancel on a move away from the part.
G41
Cutter compensation left
Compensation
Mill
Uses a D word to select the radius offset.
G42
Cutter compensation right
Compensation
Mill
Climb vs conventional depends on spindle direction and side.
G43
Tool length compensation, positive
Compensation
Mill
Uses an H word and Z move to activate.
G49
Tool length compensation cancel
Compensation
Mill
Cancels G43 and G44.
G52
Local coordinate system shift
Non-modal
Both
Temporary shift of the work coordinate system. Cancel with G52 X0 Y0 Z0.
G53
Machine coordinate system move
Non-modal
Both
Applies to the current block only.
G54
Work coordinate system 1
Work offset
Both
G54 to G59 select the first six work offsets.
G55
Work coordinate system 2
Work offset
Both
Often used for the second fixture position.
G56
Work coordinate system 3
Work offset
Both
Same family as G54.
G57
Work coordinate system 4
Work offset
Both
Same family as G54.
G58
Work coordinate system 5
Work offset
Both
Same family as G54.
G59
Work coordinate system 6
Work offset
Both
Further offsets use G54.1 P or G110 and up, depending on control.
G61
Exact stop mode
Path mode
Mill
Decelerates at every corner. Cancel with G64.
G64
Cutting (blending) mode
Path mode
Mill
Smoother motion without stopping at each block end.
G68
Coordinate system rotation
Transform
Mill
Rotates the program about a point. Cancel with G69.
G69
Coordinate rotation cancel
Transform
Mill
Cancels G68.
G73
High speed peck drilling cycle
Canned cycle
Mill
Short retract between pecks to break chips.
G76
Fine boring cycle (mill)
Canned cycle
Mill
Stops spindle and shifts the tool off the wall before retracting. On a lathe G76 is a threading cycle.
G80
Canned cycle cancel
Canned cycle
Both
Always cancel before the next unrelated move.
G81
Drilling cycle
Canned cycle
Mill
Feed in, rapid out.
G82
Drilling cycle with dwell
Canned cycle
Mill
Dwell at the bottom for spot facing or counterbores.
G83
Peck drilling cycle
Canned cycle
Mill
Full retract between pecks to clear chips. Deep holes.
G84
Tapping cycle, right hand
Canned cycle
Mill
Needs a tap holder or rigid tapping (M29 on many Fanuc-style controls).
G85
Boring cycle, feed in and feed out
Canned cycle
Mill
Spindle keeps turning on retract.
G90
Absolute programming
Distance mode
Mill
Coordinates are relative to the work zero. On many lathes G90 is a turning cycle.
G91
Incremental programming
Distance mode
Mill
Coordinates are relative to the current position.
G92
Set position / thread cycle
Setting
Both
Mill: sets a position register. Some lathe controls use G92 for threading.
G94
Feed per minute
Feed mode
Mill
F is in inches or mm per minute.
G95
Feed per revolution
Feed mode
Both
F is in inches or mm per spindle revolution.
G96
Constant surface speed
Spindle mode
Lathe
S is surface speed. Set a G50 limit first to cap RPM.
G97
Direct RPM
Spindle mode
Lathe
S is spindle RPM. Cancels constant surface speed.
G98
Return to initial level after canned cycle
Canned cycle
Mill
Retracts to the Z level before the cycle started.
G99
Return to R plane after canned cycle
Canned cycle
Mill
Retracts only to the R plane; faster between holes.
G50
Spindle speed limit / coordinate setting
Setting
Lathe
Used with S to cap RPM under G96 on Fanuc-style lathes.
G70
Finishing cycle
Turning cycle
Lathe
Finish pass along the profile defined for G71 or G72.
G71
Rough turning cycle (stock removal)
Turning cycle
Lathe
Roughs along Z using a profile defined by blocks.

Codes shown follow common Fanuc-style conventions. Haas, Siemens, Heidenhain, Mazak and others differ in details, and G-code groups, G70 to G72 and cycle formats vary by control. Always check the programming manual for your machine before running a program.

Govern CNC programs alongside ERP routings

Optional: we can discuss linking program revisions and approvals to routings and part masters.

Optional. The tool and every export work without this. No spam.

How to use the table

Type a code, function or keyword in the search box to filter the table, for example G83, tapping, or compensation. Each row gives the code, what it does, its group, whether it applies to a mill, a lathe or both, and a note about behavior or cautions. Export the table to Excel or PDF if you want a printed cheat sheet for the machine. Because controls differ, use it as a quick reminder, then confirm the exact format in your machine's manual.

Modal and non-modal codes

Most G-codes are modal: they stay active until another code in the same group replaces them. G01, G90, G17 and G54 all remain in effect across blocks. Non-modal codes such as G04, G28 or G53 apply only to the line they appear on. This is why a safe start-up line usually restates the modal states, for example G90 G54 G17 G40 G49 G80, so a program does not inherit the previous job's state.

  • Motion: G00, G01, G02, G03 (one active at a time)
  • Distance mode: G90 or G91
  • Work offset: G54 to G59 and extended offsets
  • Canned cycles stay active until G80

Controls differ

There is no single universal G-code standard. ISO 6983 defines a common core, but each builder adds extensions. G20 and G21 select units on Fanuc-style controls while older controls use G70 and G71. G90 is absolute positioning on a mill but a turning cycle on some lathe controls. G76 means a fine boring cycle on a mill and a threading cycle on a lathe. Siemens and Heidenhain use their own languages with different cycle calls. Read the manual for your specific control.

Common mistakes

Forgetting G80 after a canned cycle can cause unexpected drilling on the next move. Leaving cutter compensation active through a rapid can gouge a part. Mixing G90 and G91 without a restatement is a classic source of crashes. On lathes, running G96 without a G50 RPM cap can send the spindle to its maximum when the tool approaches the centerline. Always dry run or single block a new program with feed and rapid overrides lowered.

Frequently Asked Questions

What is the difference between G00 and G01?

G00 is a rapid, non-cutting move at the machine's traverse speed. G01 is a linear move at the programmed feed rate, used for cutting. Using G00 into material or G01 for long air moves are both common mistakes.

What does G54 do?

G54 selects work coordinate system 1, which maps program coordinates to a position on the machine set by the operator during setup. G55 to G59 select further work offsets so multiple fixtures or parts can share one program.

Are G-codes the same on every CNC machine?

No. A core set is shared, but details differ by control builder and machine type. Cycle formats, canned cycle parameters and even unit codes change. Use this table as a refresher and check the manual for your control before relying on a code.

What does it mean when a G-code is modal?

A modal code remains active until another code from the same group is programmed. For example, once G01 is active it applies to following moves until G00, G02 or G03 replaces it. Non-modal codes apply only to their own block.

If CNC programs, revisions and approvals are managed by file shares rather than your ERP or PLM, Netray can help connect them to part and routing records with read-only controls.