A finished CNC program looks like a wall of letters and numbers, but it follows a strict, simple grammar. Once you know how a block is built, you can read any program top to bottom without guessing.

A program is a list of blocks

The control runs the program one block (line) at a time, in order, from the top down. It never jumps ahead unless a code tells it to. So reading a program is just reading each line the same way the machine will execute it: left to right, then down to the next.

Each block is made of words. A word is a single letter, called the address, followed by a number. In G01 X50. F150, there are three words: G01, X50., and F150. This letter-plus-number structure is the word address format that CNC controls have used since the earliest numerical control machines.

What each address letter means

A handful of letters do almost all the work. Learn these and most of a program is readable:

AddressMeaningExample
NLine number (optional label)N50
GMotion or mode (preparatory)G01 feed move
MMachine action (miscellaneous)M03 spindle on
X Y ZAxis coordinatesX50. Y25. Z-5.
FFeedrateF150
SSpindle speedS1200
TTool selectT1
H DOffset register (length, diameter)H01

G and M are the two you decode most. G words set how the machine moves and what mode it is in; M words turn things on and off, like the spindle and coolant. The full meaning of each is listed in the LinuxCNC G-code reference and on any good G-code cheat sheet.

A real program, line by line

Here is a short milling program in a common Fanuc style. Read it block by block:

%
O1000
G21 G17 G40 G90
T1 M06
G54
S1200 M03
G00 X0 Y0
G43 Z25. H01
G01 Z-5. F100
G01 X50. F150
G00 Z25.
M05
M30
%

Now the same program decoded:

BlockWhat it does
%Start and end marker for the file
O1000Program number (its name on the control)
G21 G17 G40 G90Metric units, XY plane, cutter comp off, absolute mode
T1 M06Select tool 1, then change to it
G54Use work offset 1 as the part zero
S1200 M03Spindle to 1200 rpm, start clockwise
G00 X0 Y0Rapid to the start point (not cutting)
G43 Z25. H01Turn on tool length offset H01, rapid to a safe Z
G01 Z-5. F100Feed straight down to depth at 100 mm/min
G01 X50. F150Feed in a straight line, cutting, at 150 mm/min
G00 Z25.Rapid back up to clearance
M05Stop the spindle
M30End the program and rewind

Notice the order: the top four lines are pure setup (units, plane, tool, offset, spindle), then the middle lines are motion, then the last two shut down. Almost every program follows that shape.

Track the modes as you read

The trickiest part for beginners is that many codes are modal: once set, they stay active until something changes them. After G90, every coordinate is absolute until a G91 appears. After G01, the machine keeps feeding for every following coordinate-only line until another motion code is set. So you cannot read a line in isolation, you have to carry the active modes down the page. This is the single idea behind modal vs non-modal G-codes, and getting it wrong is a classic crash cause. Once the modes come naturally, the next step is reading a whole program by its structure, the approach in understanding a CNC program as an operator.

The codes worth knowing cold

You do not need to memorize hundreds of codes to read a program. The motion pair G00 vs G01 covers most movement, and the rest of the everyday set is short. Start with the common G-codes for CNC beginners and the matching common M-codes for CNC beginners, and you will recognize the great majority of lines in any program. A few from the setup block are worth knowing on their own: inch versus metric (G20 vs G21), plane selection (G17, G18, G19), and the drilling canned cycles (G81 vs G83) you meet as soon as a program bores holes.

Bottom line

Reading CNC code is not about memorizing a manual. It is reading blocks in order, decoding each word as a letter plus a number, and tracking which modes are active. Learn the dozen everyday codes, practice them until recognition is instant, and any program becomes readable.

Sources

Frequently asked questions

How do you read a CNC program for beginners?

Read it the way the machine runs it: one block at a time, top to bottom, left to right. Decode the setup lines first (units, plane, work offset, tool, spindle), then follow the motion lines in order, carrying the active modes down the page.

What do the letters in a CNC program mean?

G sets motion and mode, M is a machine action, X Y Z are coordinates, F is feedrate, S is spindle speed, T selects a tool, and H or D point to an offset register. N just labels the line.

Do all CNC machines read the same G-code?

The core codes are nearly universal, but setup details, canned cycles, and macros differ by control, so confirm against your machine’s manual before running.

What is the best way to practice reading CNC code?

Drill the codes with active recall, not by re-reading a chart. A free app like G-Code Sprint shows codes as quick timed questions and repeats the ones you miss, so line-by-line reading becomes automatic.

G-Code Sprint is a study and practice tool only. Always follow your instructor, employer, machine manual, and shop safety procedures.