# What Is G-Code in CNC Programming

G-code is the instruction language CNC machines read. Learn what each block does, how motion commands differ, and how G and M codes work together.

G-code is the step-by-step instruction language that a CNC machine reads to move its axes and control its functions. Each line of g code programming tells the machine one thing to do, such as move to a position, turn the spindle on, or change a tool. The basics of cnc programming with g code come down to a small set of commands and a strict block structure. This page explains what the commands mean and how a program is built from them. 

## One line, one block, one job 

A block is a single line of a cnc g code program, and it holds the commands for one movement or one machine action. Words inside a block pair a letter with a number, and the letter gives the word its type. A block may contain several words, and the control reads them together as one instruction. Reading broken block structure first makes the rest of a program much easier to follow. 

## Motion commands G00 and G01 

Motion commands tell the machine where to go and at what feed rate to travel. G00 moves the tool rapidly to a position, and machine control instructions handle this without cutting material. G01 moves at the programmed feed rate, so G01 is the command for a cutting move through metal or plastic. Choosing between them decides whether the tool travels or cuts. 

## G codes and M codes work together 

G codes control motion and geometry, while M codes control the machine's switching functions. Spindle start and stop, coolant on and off, and program end belong to the M group of machine control instructions. A program alternates between both groups as the job moves from one operation to the next. Understanding g and m codes as separate families keeps a new program readable and easy to trace. 

## Questions About G-Code Programming 

### Is g code a programming language? 

Yes, g code is a programming language, though a simple one with a narrow purpose. It is the programming language for cnc machines, written for motion and machine control rather than for logic or software. A person writes commands in sequence, and the control executes that sequence line by line. It works like a program because it holds instructions, order, and feed and speed values. 

### What are the g code basics for cnc programming? 

The g code basics are block structure, motion commands, and machine control instructions. A beginner should learn how a block is written, how G00 and G01 differ, and how M codes switch machine functions. Feed rate and spindle speed belong with these basics because motion without them is incomplete. Master that set before writing longer cnc programming g code sequences. 

### Do I write g code by hand or with CAM software? 

Both paths exist, and the choice depends on the part and the shop. Hand programming in g code suits simple geometry and edits at the machine, where an operator changes one line. CAM software generates g code from a model and suits complex surfaces too long to type. Reading the output still requires knowing the language, because the operator signs off on the program. 

### Why does g code differ between machine controls? 

Machine control instructions are not fully identical across controls, so g code dialect varies by builder. Many codes follow a shared standard, while cycles and special functions differ between makes and models. An operator moves a program to a different machine only after checking that control's manual. The program structure carries over, but the details need a look before the first run.
