---
title: "How to Read a CNC Program for Beginners"
description: "A CNC program is read one block at a time, top to bottom. Here is how to decode each line of a real program, the letters that matter, and how to get fluent."
url: https://gcodepractice.com/journal/how-to-read-a-cnc-program-for-beginners/
canonical: https://gcodepractice.com/journal/how-to-read-a-cnc-program-for-beginners/
author: "Lawrence Arya"
authorUrl: https://www.linkedin.com/in/vibecoding/
published: 2026-06-04
updated: 2026-06-04
category: "Guides"
tags: ["g-code", "beginner", "reading-code", "cnc-program"]
lang: en
---

# How to Read a CNC Program for Beginners

> **TL;DR** A CNC program is a list of blocks (lines) the control runs in order from top to bottom. Each block is made of words: a letter address (G, M, X, Y, Z, F, S, T) followed by a number. Read left to right, track which modes are active, and most programs become predictable. Learn the dozen most common codes and the rest is just coordinates.

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](https://en.wikipedia.org/wiki/G-code) 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:

| Address | Meaning | Example |
| --- | --- | --- |
| `N` | Line number (optional label) | `N50` |
| `G` | Motion or mode (preparatory) | `G01` feed move |
| `M` | Machine action (miscellaneous) | `M03` spindle on |
| `X` `Y` `Z` | Axis coordinates | `X50. Y25. Z-5.` |
| `F` | Feedrate | `F150` |
| `S` | Spindle speed | `S1200` |
| `T` | Tool select | `T1` |
| `H` `D` | Offset 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](https://linuxcnc.org/docs/html/gcode/g-code.html) and on any good [G-code cheat sheet](https://www.cnccookbook.com/g-code-m-code-cnc-list-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:

| Block | What it does |
| --- | --- |
| `%` | Start and end marker for the file |
| `O1000` | Program number (its name on the control) |
| `G21 G17 G40 G90` | Metric units, XY plane, cutter comp off, absolute mode |
| `T1 M06` | Select tool 1, then change to it |
| `G54` | Use work offset 1 as the part zero |
| `S1200 M03` | Spindle to 1200 rpm, start clockwise |
| `G00 X0 Y0` | Rapid to the start point (not cutting) |
| `G43 Z25. H01` | Turn on tool length offset H01, rapid to a safe Z |
| `G01 Z-5. F100` | Feed straight down to depth at 100 mm/min |
| `G01 X50. F150` | Feed in a straight line, cutting, at 150 mm/min |
| `G00 Z25.` | Rapid back up to clearance |
| `M05` | Stop the spindle |
| `M30` | End 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](/journal/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](/journal/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](/journal/g00-vs-g01/) covers most movement, and the rest of the everyday set is short. Start with the [common G-codes for CNC beginners](/journal/common-g-codes-for-cnc-beginners/) and the matching [common M-codes for CNC beginners](/journal/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)](/journal/g20-vs-g21-inch-vs-metric/), [plane selection (G17, G18, G19)](/journal/g17-g18-g19-plane-selection-explained/), and the [drilling canned cycles (G81 vs G83)](/journal/g81-vs-g83-drilling-canned-cycles/) 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

- [Wikipedia: G-code (word address format)](https://en.wikipedia.org/wiki/G-code)
- [LinuxCNC G-code reference (modal groups)](https://linuxcnc.org/docs/html/gcode/g-code.html)
- [CNCCookbook: G-code and M-code cheat sheet](https://www.cnccookbook.com/g-code-m-code-cnc-list-cheat-sheet/)

## 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.*

---

Source: https://gcodepractice.com/journal/how-to-read-a-cnc-program-for-beginners/
Author: Lawrence Arya — https://www.linkedin.com/in/vibecoding/
