G-Code Cheat Sheet

A quick reference to the G-codes and M-codes you use most. G-codes control geometry and motion; M-codes control machine functions like the spindle and coolant. Exact behavior can vary by controller, so always confirm against your machine post.

Modal vs non-modal: most motion codes (G00, G01, G90) stay active until replaced; codes like G04 act once. A typical line reads like G01 X1.0 Y0.5 F10.

Common G-codes

Code Function
G00 Rapid positioning (non-cutting move)
G01 Linear feed move (straight cut)
G02 Circular interpolation, clockwise (arc)
G03 Circular interpolation, counterclockwise
G04 Dwell (timed pause)
G17 / G18 / G19 Select XY / XZ / YZ working plane
G20 / G21 Units in inches / millimeters
G28 Return to machine home
G40 Cancel cutter compensation
G41 / G42 Cutter compensation left / right
G43 Apply tool length offset
G54–G59 Work coordinate systems (part zero)
G80 Cancel canned cycle
G81 Standard drilling cycle
G83 Peck drilling cycle
G90 / G91 Absolute / incremental positioning

Common M-codes

Code Function
M00 Program stop
M01 Optional stop
M03 / M04 Spindle on clockwise / counterclockwise
M05 Spindle stop
M06 Tool change
M08 / M09 Coolant on / off
M30 Program end and rewind

Reference set for milling controls. Lathe and multi-axis machines add codes (constant surface speed, tool nose comp); check your controller manual.

For the spoken vocabulary behind the codes, see the Machining Glossary, and run setup numbers in G-code & CNC calculators.

Scroll to Top

The calculators and tools on Formula Factory are provided for general guidance and informational purposes only. Results are estimates based on standard formulas and the values you enter — they do not constitute professional engineering, electrical, or architectural advice. Always verify calculations with a qualified professional before making decisions for any safety-critical, code-compliance, or commercial application. Formula Factory makes no representations or warranties as to the accuracy or completeness of any result, and accepts no liability for errors, omissions, or any outcomes arising from reliance on this information.