Skip to main content
Machinist Free Pro Features Available

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.

Pro Tip: Memorize 10 codes and you can read 90% of any program: G00 (rapid), G01 (linear feed), G02/G03 (circular), G28 (home), G43 (tool length comp), G54 (work offset), G80 (cancel cycle), G81 (drill), M03/M05 (spindle), M30 (end program).

PREVIEW All Pro features are currently free for a limited time. No license key required.

CNC G-Code Quick Reference

How It Works

  1. Search or Browse

    Type a code number (G81) or keyword (drill, coolant) in the search box, or browse the full categorized list.

  2. Filter by Type or Machine

    Show only G-codes or M-codes. Further filter by Mill, Lathe, or Both.

  3. Expand Code Details

    Click any code card for full syntax format, parameter definitions, and usage notes.

  4. Review Syntax Examples

    Every code includes real-world syntax examples with all required parameters.

  5. 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)

Frequently Asked Questions

Core ANSI/ISO codes (G00/G01/G02/G03, G28, G43, G54, G80-89, M03-09, M30) are standardized across platforms. Manufacturers add proprietary codes for advanced features.
G00 moves at maximum machine speed (non-cutting). G01 moves at programmed feed rate (cutting). Never use G00 for cutting moves.
R is the reference plane — the Z height where rapid-to-feed transition occurs. Set slightly above the workpiece surface (0.050-0.100").
G90 is absolute (coordinates from work zero). G91 is incremental (coordinates from current position). Most programs use G90 for clarity.
Disclaimer: Descriptions based on ANSI/ISO standards and common implementations. Specific syntax may vary by control manufacturer and model. Always verify in your machine's programming manual. Test new programs in single-block mode.

Learn More

Machinist

CNC G-Code Basics: What Every Machinist Should Know

Foundational CNC G-code and M-code knowledge for machine shop operators. Code structure, modal groups, program flow, and common codes for mills and lathes.

Related Tools

Machinist Live

Chip Load Calculator

Calculate chip load per tooth for milling, drilling, and turning. Forward and reverse modes with material-specific recommendations, chip thinning factor, and MRR. Metal and wood modes.

Machinist Live

Thread Pitch Identifier

Identify unknown threads from caliper measurements. Cross-references UNC, UNF, Metric ISO, NPT, BSP, and ACME thread standards with tolerance matching and confidence scoring.

Machinist Live

Tolerance & Fit Calculator

ISO 286 tolerance zone calculator for shaft/hole fits. Calculates clearance, transition, and interference fits with visual tolerance zone diagram and common fit presets (H7/g6, H7/h6, H7/p6, etc.).