# CNC G-Codes

Learn what CNC G-codes are, how G-code words are built and read line by line, which motion codes move the tool, and how to check a program before a run.

CNC G-codes are the letter-G instruction words in a G-code program that tell a CNC machine which action to take, such as move in a straight line, feed at a set rate, or select a work offset. The machine reads the program as a block of commands and executes them in order. This page explains the structure of a G-code program, the motion codes a machinist works with, and how to verify a program before the tool meets material. 

## How a G-code word is built 

A G-code program is a text file of numbered blocks, and each block holds address words that act together. The letter G selects the preparatory action, while X, Y and Z set coordinates and F sets feed rate. Modal codes stay active after their block runs, which means a motion mode keeps applying until another G-code replaces it. Mixing incompatible modal states is what causes most unexpected moves. 

## Motion commands that move the tool 

G00 positions the tool at rapid traverse and serves travel between cuts, not cutting. G01 moves the tool in a straight line at the programmed feed rate and is the main cutting command. G02 and G03 cut clockwise and counterclockwise arcs, and each arc block needs the endpoint plus a center reference. Selecting the correct plane for an arc prevents a machine from rejecting the block. 

## Checks before a program run 

A setup is verified by running the program above the part with the tool clear of all fixtures. Work offsets in the offset table decide where the part sits in machine space, so a wrong offset throws off every coordinate. Feed and speed values are set for the material and tool, not copied from another job without thought. A machinist checks tool length offsets on each tool before the first cutting move. 

## Questions about CNC G-Codes 

### What are CNC G-codes used for? 

CNC G-codes are used to command machine actions inside a G-code program, such as motion mode, plane selection and tool change calls. A CAM system or a person writes the codes as text blocks, and the machine controller reads them line by line. The codes prepare the machine, while coordinate and feed words supply the values for each action. 

### Is G-code the same as CNC programming? 

No, G-code is the language a CNC program is written in, while CNC programming is the wider work of planning the job. CNC programming covers stock choice, tool choice, workholding, cut strategy and then the G-code itself. A programmer may post the code from CAM software or write it at the control. 

### Why does my machine ignore a G-code? 

A machine may ignore a G-code that is not active in the current mode or not supported by its controller. Modal state from an earlier block can also override what the line intends. Compare the block with the machine manual, since supported codes and their exact behavior differ between controls. 

### Should I learn G-codes before running a CNC machine? 

Yes, learning G-codes helps before running a CNC machine because you can then read the program the machine will execute. Comprehension of the block order and modal state lets you spot a wrong coordinate or offset before a crash. Hands-on work still belongs under the supervision of an experienced operator until the process is proven.
