G-code and M-code basics for CNC beginners

By the CAD CAM Galaxy team · Updated 16 Nov 2026

G-codes tell a CNC machine how to move (rapid move, straight cut, arc, plane, units). M-codes switch machine functions (spindle, coolant, tool change, program end). Controls differ, so always check the manual for your machine, but the common codes below are widely used on Fanuc-style controls.

Common G-codes

CodeMeaning
G00Rapid move (not for cutting)
G01Straight-line cutting move at the set feed rate
G02 / G03Circular arc, clockwise / counter-clockwise
G17 / G18 / G19Select the XY / XZ / YZ plane
G20 / G21Inch / millimetre units
G54 to G59Work coordinate systems (work offsets)
G90 / G91Absolute / incremental positioning

Common M-codes

CodeMeaning
M03 / M04Spindle on clockwise / counter-clockwise
M05Spindle stop
M06Tool change
M08 / M09Coolant on / off
M30Program end and rewind

Do you still need G-code if CAM writes it?

Yes. CAM generates the code, but the person at the machine must be able to read it: to find where a program stopped, to edit a feed, to check an offset or to spot a wrong move before it crashes the tool. Reading G-code is a safety skill as much as a programming one.

Need help or a quotation?

CAD CAM Galaxy supplies licensed CAD/CAM software and trains engineers across India, with centres in Mumbai, Palghar and Vapi. Use the form below or see the related pages.

Get a quote for your licences

Tell us which software you need, how many seats, and what your team machines or designs. We quote, supply, install and support — and reply within one working day.

Hours

Mon – Sat: 10:00 AM – 7:00 PM

WhatsApp Call us