Free tools Windows power users keep installed
One-click scans. No signup required.
Read a CNC program one block at a time: identify each command, read the values attached to it, then account for modes left active by earlier blocks. G-code charts are useful guides, not universal rulebooks—your machine’s controller and post processor determine how a file is interpreted.
How do I read G-code?
A CNC program is a sequence of lines, often called blocks. Each word generally pairs a letter with a value; several words on one block work together as a command and its arguments. LinuxCNC’s documentation puts it this way: “A word may either give a command or provide an argument to a command.” (LinuxCNC, Overview of G-Code Programming)
- Identify the command. A G word commonly specifies a general function or motion; an M word commonly controls a miscellaneous machine function.
- Read the attached values. Axis addresses such as X, Y, and Z specify positions. F commonly specifies feed rate, S spindle speed, and T tool selection. These are common conventions, not a promise that every controller assigns every code identically. (Autodesk’s beginner overview of G-code)
- Carry forward active modes. A block may omit a setting because an earlier block established it. Modal commands stay in effect until changed or cancelled; Autodesk uses M03 to start a spindle and M05 to stop it as examples of commands whose effect persists. (Autodesk’s beginner overview of G-code)
- Check setup context. Before interpreting a longer program, establish the units, absolute or incremental positioning, active plane, work offset, tool compensation, feed, spindle state, and selected tool. The relevant commands and defaults vary by controller.
- Confirm the dialect. Identify the machine controller and the post processor that generated the file before relying on a generic chart.
What do G and M codes mean on a CNC machine?
G codes typically describe general functions, including motion and setup modes. M codes typically control miscellaneous machine actions. The address letters that follow or accompany them supply parameters, such as a destination, feed rate, spindle speed, or tool selection. These categories are a starting point for reading; the controller’s documentation defines the exact behavior.
Common G-code examples in the LinuxCNC reference
| Code | LinuxCNC reference meaning | What to verify |
|---|---|---|
| G0 | Coordinated rapid motion | Rapid behavior and limits depend on machine configuration. (LinuxCNC G-code quick reference) |
| G1 | Coordinated feed motion | Feed and destination depend on active units and coordinate system. (LinuxCNCC G-code quick reference; LinuxCNC overview) |
| G2/G3 | Feed-rate helical motion commands | Arc arguments and plane conventions require the target controller’s documentation. (LinuxCNC G-code quick reference) |
| G20/G21 | Units-of-measure commands | Check the controller’s definitions and confirm the active inch or millimetre mode. (LinuxCNC G-code quick reference) |
| G17–G19.1 | Plane-selection commands | The active plane affects how arc moves are interpreted. (LinuxCNC G-code quick reference) |
These descriptions are specifically from LinuxCNC’s reference, not universal definitions for every CNC control.
#1 Best Overall
Common M-code examples
Autodesk illustrates M03 as starting the spindle and M05 as stopping it; treat these as examples and confirm the machine’s own M-code definitions. (Autodesk’s beginner overview of G-code) In LinuxCNC, M2 and M30 are program-end commands. That statement describes LinuxCNC behavior; check another controller’s manual before assuming the same end-of-program behavior. (LinuxCNC M-code reference)
What does G1 X3 mean?
In LinuxCNC’s documented example, G1 X3 commands a straight move at the programmed feed rate, ending at X=3. G1 supplies the feed-motion command; X3 gives the destination value in the active coordinate system. (LinuxCNC, Overview of G-Code Programming)
Adding a feed word gives an illustrative block such as G1 X3 F20: a feed-rate linear move to X=3 with a programmed feed value of 20, subject to the active coordinate system, units, and controller interpretation. The snippet alone does not establish whether the position is inches or millimetres, whether X is absolute or incremental, or what physical distance the feed value represents.
Why does my CNC controller use different G-code?
G-code has dialects: machine and controller makers can implement codes differently, and a code or parameter accepted by one control may not transfer safely to another. Autodesk advises consulting the machine’s instruction manual for a specific function. (Autodesk’s beginner overview of G-code)
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Rank #3
CAM software also matters. It post-processes toolpaths into NC code for a target machine, and Fusion’s NC Program settings depend on the selected machine or post processor. (Autodesk Fusion: NC Program reference) A program can therefore look familiar while still relying on controller-specific conventions. Check that the post processor matches the machine and control, then verify unfamiliar commands in the machine’s current documentation.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.How to read a longer program safely
- Locate the program’s setup and opening blocks; determine units, positioning mode, plane, coordinate origin or work offset, and any active compensation.
- Track modal commands as the program progresses. Do not treat an omitted word as a reset; verify the control’s modal groups and defaults.
- For each motion block, read the motion command together with axis values and the active feed, units, and coordinate system.
- Check tool selection, spindle commands, and tool-change behavior against the machine’s documentation.
- Confirm which controller and post processor produced the file. A generic code chart cannot establish compatibility.
- Use the machine manual and the shop’s established setup and simulation procedures. Reading text is a learning aid, not proof that a program is safe to run.
LinuxCNC’s online reference covers topics including units, plane selection, motion, coordinate origins, and tool-table functions. Its documentation index identifies version 2.9.10, which is a documentation version—not an industry statistic or a claim about another controller. (LinuxCNC documentation index)
Quick Recap
Rank #4
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




