CNC G-Code & M-Code Quick Reference - Searchable Mill & Lathe Guide
Look Up Common G-Codes and M-Codes with Syntax Examples
Free searchable G-code and M-code reference with ~45 G-codes and ~15 M-codes. Each includes plain-English description, syntax example, and mill vs lathe applicability. Controller-agnostic content covers ANSI/ISO standard codes.
Includes search, code type filter, machine filter, category filter, expandable code cards with parameter descriptions, and quick-find shortcuts for common operations.
Read the CNC G-code basics guide
CNC G-Code Basics Guide →Calculate speeds and feeds
Speeds & Feeds Calculator →Build a CNC job setup planning sheet
Job Setup Planning Sheet →Calculate surface finish from feed rate
Surface Finish Calculator →How It Works
-
Search or Browse
Type a code number (G81) or keyword (drill, coolant) in the search box, or browse the full categorized list.
-
Filter by Type or Machine
Show only G-codes or M-codes. Further filter by Mill, Lathe, or Both.
-
Expand Code Details
Click any code card for full syntax format, parameter definitions, and usage notes.
-
Review Syntax Examples
Every code includes real-world syntax examples with all required parameters.
-
Use Quick-Find Shortcuts
Links to most-needed codes: Drill, Peck Drill, Tool Change, Cutter Comp, etc.
Built For
- CNC operators looking up unfamiliar codes in existing programs
- Beginning programmers learning G-code and M-code vocabulary
- Setup technicians verifying canned cycle syntax
- Manual programmers writing G-code at the control
- Instructors teaching CNC programming fundamentals
- Maintenance technicians reading programs to diagnose machine issues
Features & Capabilities
~45 G-Codes
Motion, coordinate system, canned cycles, cutter compensation, and work coordinate codes.
~15 M-Codes
Program control, spindle, tool change, coolant, subprogram calls.
Controller-Agnostic
ANSI/ISO standard codes common to Fanuc, Haas, Mazak, and other platforms.
Mill vs Lathe Tags
Each code tagged Mill, Lathe, or Both for relevance filtering.
Search and Filter
Full-text search plus category and machine type filters.
PDF Export
Export as branded PDF for machine-side posting or training binders.
Assumptions
- G-code and M-code descriptions based on ANSI/EIA RS-274-D and ISO 6983 standard code definitions
- Syntax examples formatted for Fanuc/Haas-compatible controllers, which represent the most common platform in North America
- Canned drilling cycles (G73, G76, G81-G89) assume standard modal behavior where R-plane and Z-depth remain active until canceled
- Work coordinate system codes (G54-G59) follow standard 6-offset convention; extended offsets vary by manufacturer
- M-code numbering follows Fanuc convention; Mazak, Okuma, and Siemens use different M-code assignments for some functions
- Feed rate interpretation assumes G94 (inches per minute) for milling and G95 (inches per revolution) for turning unless stated
Limitations
- Proprietary manufacturer codes (Mazak G-codes, Siemens cycles, Okuma OSP codes) are not covered
- Conversational and graphical programming interfaces (Mazak Mazatrol, Hurco WinMax) use entirely different syntax
- Advanced features (NURBS interpolation, 5-axis RTCP, high-speed machining modes) are controller-specific and not documented here
- Macro programming (Fanuc Custom Macro B, Haas macros) syntax and variables are beyond the scope of this reference
- Lathe-specific codes for live tooling, sub-spindle, and Y-axis operations vary significantly by manufacturer
- Does not include post-processor customization guidance for CAM-generated G-code output
References
- ANSI/EIA RS-274-D - Interchangeable Variable Block Data Format for Positioning, Contouring, and Contouring/Positioning Numerically Controlled Machines
- ISO 6983 - Numerical Control of Machines - Program Format and Definitions of Address Words
- Fanuc Series 0i/30i/31i Operator's Manual - Programming (standard G-code and M-code reference)
- Haas CNC Mill and Lathe Operator's Manual - G-Code and M-Code Reference
- Machinery's Handbook, 31st Edition - CNC Programming and G-Code Reference Tables
- Peter Smid - CNC Programming Handbook, 3rd Edition (comprehensive G-code programming reference)