Online Manufacturing for Metal parts and Plastic Parts, XTJ Precision Mfg Ltd

Mobile: +86 17704021786

How Many G-codes Are There in a CNC Machine

cnc machining

There are over a hundred G-code commands for CNC programming.

Most of the G-codes are common for every CNC programming operation. However, certain G-codes are specific to the type of operation like milling, turning, drilling, etc.

There can be variation in the G-code list between the different CNC manufacturers.

Every machine does not support every G-code. Additionally, machines with unique features or multi-axis machining capabilities might have additional G-codes. The manufacturer may provide instructions on the G-codes for CNC programming in the reference annual provided with the machine.

What are the Common G-code Commands Used in CNC Machines?

?There are over a hundred G-codes used in the CNC programming process. Therefore, it can be difficult to memorize all the individual codes and their meanings.

Below is a G-code list for the commonly used commands in the CNC programming process.

You can use this list as a reference point when writing any CNC programming file. It is useful to memorize important commands such as the G00-G03 as they are used throughout every CNC programming project.

CNC Movement and Travel
The codes below are used for controlling the movement and tool path in the CNC programming:

G00: Rapid Move of the Machine Tool
Rapid move command moves the tool from one point to another without cutting the material. The movements are done at highest speed possible. Therefore, no feed rate is required for the rapid move commands. It requires location coordinates in the X axis, Y axis, and Z axis.

G01: Linear Interpolation of the Machine Tool
Linear interpolation moves the tool from one point to another in a straight line. The speed is according to a feed rate specified by ‘F’ in the G01 command block.

G02: Clockwise Arc Circular Interpolation
Instead of a straight line, G02 commands the cutting tool to cut in an arc in the clockwise direction. It requires a feed rate specified by the value ‘F’. It requires the specification of the center point (I, J, K) or the radius (R) of the arc.

G03: Counter Clockwise Arc Circular Interpolation
Same as G02. instead of clockwise direction, it cuts an arc in the counterclockwise direction.

G04: Dwell
Dwell indicates a pause in the program. It ceases the machine movements but the auxiliary functions stay on. For instance, the spindle keeps on moving while the program is in Dwell mode. The duration of the dwell is indicated by pause time ‘P’. The machine reads the P value in seconds.

G09: Exact Stop
The exact stop G-code is used when a sharp corner is required. Conventional machining creates rounded corners due to the inertia of the cutting tool. G09 elimiantes this problem by stopping the cutting tool temporarily at the corner and then moving it again, leading to perfectly sharp corners.

Plane Selection
Plane selection G-code programs specify the two-dimensional plane in the X, Y, Z axis cartesian coordinate system. These commands are:

G17 – XY Plane Selection
G18 – XZ Plane Selection
G19 – YZ Plane Selection
G-code programs for dimensions indicate which measurement units are chosen. These commands are:

G20: Change unit measurement to inches
G21: Change unit measurement to millimeters
Compensation Codes
Cutter compensation codes consider parameters such as the tool length and tool radius. Using these commands can increase the precision of the overall CNC operation.

They are also known as tool offsets. These commands are:

G40 – Turn off tool compensation
G41 – Cutter compensation left
G42 – Cutter compensation right
G43 – Tool length compensation
G40 – Cancel tool length compensation
Work Offsets
Work offset ensures that the workpiece is at the true zero position. The commands for work offset values are:

G54 – Work Offset 1
G55 – Work Offset 2
G56 – Work Offset 3
G57 – Work Offset 4
G58 – Work Offset 5
G59 – Work Offset 6
Canned Cycles
A canned cycle in CNC is a repetition of a particular machine operation such as drilling, reaming, tapping, boring, etc. Some of the common canned cycle G-code programs are:

G73 – High-Speed Peck Drilling Canned Cycle. Drill holes while breaking chips
G74 – Peck drilling canned cycles generally used for face grooving. Use for tapping only.
G75- Quick grooving cycle for CNC lathes
G76 – Fine Boring Canned Cycle and threading cycle
G81 – Standard Drilling Canned Cycles
G82 – Standard Drill with Dwell at the bottom of the hole
G83 – Deep Hole Peck Drilling Cycle Retracting All Through the Hole
G84 – Right-Hand Tapping Cycle For Machining Threads Into Pre-drilled Holes
G85 – Reaming Cycle or Boring Cycle
G86 – Bore and Stop Canned Cycle; Spindle Stops When Tool Reaches the Bottom of the Hole
G87 – Boring cycle with a special tool for expanding diameter of hole
G88 – Boring Cycle with P instruction; P instructs the number of seconds to dwell
G89 – Back Boring Cycle with Dwell
Cancel Codes
G50: Scaling off; in some machines it may be used for programming absolute zero center point or for setting spindle speed limit
G80: Cancel all active canned cycles
Positioning Modes
The positioning mode refers to how the CNC machine will read the position commands. The G-code program for various positioning modes are:

G90 – Use absolute mode for positioning
G91 – Use incremental positioning
Speeds and Feeds
Speed and feed mode refer to how the machine interprets the value units. These commands are:

G94 – Feed per Minute Mode
G95 – Feed per Revolution Mode
G96 – Constant Surface Speed
G97 – Constant Spindle Speed
Plane Return
Plane return commands contemplate the cutting tool location in various planes. Common plane return commands are:

G98 – Return to Initial Plane
G99 – Return to Rapid Plane
Lesser Used G Codes
Some of the G-codes are not as common as the ones listed above. However, you may need them now and then for specific program requirements. Here is a list of some of the lesser used G-code:

G10 – Programmed Offset Input
G22 – Stored Stroke Limit
G23 – Stored Stroke Limit Cancel
G27 – Zero Return Check
G28 – Zero Return
G29 – Return From Reference Position
G30 – Second Position Zero Return
G31 – Skip Function
G44 – Negative Tool Length Compensation
G45 – Single Offset Increase
G46 – Single Offset Decrease
G47 – Double Offset Increase
G48 – Double Offset Decrease
G51 – Scaling
G52 – Temporarily Shift Program Zero
G53 – Return to Machine Zero Position
G60 – Single Direction Move
G61 – Exact Stop Check (Modal)
G64 – Normal Cutting Mode
G65 – Custom Macro Call
G66 – Custom Macro Modal Call
G67 – Cancel Custom Macro Modal Call
G68 – Coordinate Rotation Mode
G69 – Cancel Coordinate Rotation Mode
G92 – Program a Work Offset

Are There Any Safety Considerations When Programming G-code For CNC Machines

Yes, some safety considerations exist when programming G-code for a CNC machine. A CNC machine is capable of cutting material of extreme hardness.

Therefore, incorrect G-code can be a safety hazard for the machine, the operator, and the work area. The G-code should consider factors such as the work offsets and tool length offsets to ensure there is no tool breakage.

Tool breakage is a frequent accident that occurs due to tool collisions. Running prior simulations in CAD and CAM software can eliminate any chances of errors and bugs in the G-code.


XTJ is a leading OEM Manufacturer that is dedicated to providing one-stop manufacturing solutions  from prototype to production. We are proud to be an ISO 9001 certified system quality management company and we are determined to create value in every customer relationship. We do that through collaboration, innovation, process improvements, and exceptional workmanship.




Make the best product possible with the help of our international team of experts. When you’re ready for a project review, contact us for a free quote.

Contact Form Demo (#3)