G-code
G-code is the common name for the word-address programming language used by most CNC machines. Each block combines letter addresses and numbers that set motion type, coordinates, feed, spindle speed and tool.
A G-code program is a sequence of blocks, each made of words such as G01, X25.0 or F300. Preparatory G words set the type of motion and the operating mode, for example G00 for rapid positioning, G01 for straight-line feed, G02 and G03 for clockwise and anticlockwise arcs, G17 to G19 for plane selection and G90 or G91 for absolute or incremental coordinates. Other addresses carry axis positions, feed rate (F), spindle speed (S), tool number (T) and miscellaneous machine functions (M). Many codes are modal, so they stay active until another code in the same group replaces them.
G-code is used on milling machines, lathes, routers, grinders and many other CNC machines. Most production programs are generated by CAM software through a post-processor, while short programs, edits and probing routines are often written by hand at the control.
The language was standardised as EIA RS-274-D and ISO 6983-1, but every control family implements its own dialect, so a program written for one control may behave differently on another. Programs should be verified by simulation and a careful prove-out before production. Richer, feature-based alternatives such as STEP-NC (ISO 14649) exist but are far less widely deployed.
Key points
- Blocks are built from letter-address words such as G, X, Y, Z, F, S, T and M
- G00, G01, G02 and G03 are the widely used motion codes
- Modal codes stay active until replaced by another code in the same group
- Standardised as RS-274-D and ISO 6983-1, but dialects differ between controls
Where AiVibe comes in
AiVibe designs and manufactures the AiAmbA AI Factory: edge devices plus AI agents that let people talk to CNC, PLC and robot controllers in plain language. Agents only propose changes, and a trained operator confirms each one.
Related terms
- M-code (Miscellaneous Function)CNC & Precision Machining
- CNC Machine (Computer Numerical Control)CNC & Precision Machining
- Post-ProcessorCNC & Precision Machining
- Canned Cycle (Fixed Cycle)CNC & Precision Machining
- Macro Programming (Parametric Programming)CNC & Precision Machining
- CNC Program Verification and SimulationCNC & Precision Machining
Terms that refer to G-code
- CNC ControllerCNC & Precision Machining
- Computer-Aided Manufacturing (CAM)CNC & Precision Machining
- Cutter Radius Compensation (G41, G42)CNC & Precision Machining
- DNC (Distributed or Direct Numerical Control)CNC & Precision Machining
- Linear and Circular Interpolation (G01, G02, G03)CNC & Precision Machining
- Work Offset (Work Coordinate System, G54 to G59)CNC & Precision Machining