G-code reference
G21 G-Code: Metric Input
Metric Input — Interprets all following dimensions in millimetres (feeds in mm/min or mm/rev). On Siemens the equivalent is G71.
| Property | Value |
|---|---|
| Code | G21 |
| Function | Metric Input |
| Modal group | 06 |
| Type | Modal — stays active until replaced by another code of the same group |
| Used on | Mills and lathes |
| Syntax | G21 |
What does G21 do?
Interprets all following dimensions in millimetres (feeds in mm/min or mm/rev). On Siemens the equivalent is G71.
G21 is modal: once programmed it remains in effect for the following blocks until another code from modal group 06 replaces it or the control is reset.
Syntax and parameters
G21G21 example program
G21 (metric)
G17 G40 G49 G80 G90▶ Open this example in the G-code viewer
Tips and common mistakes
- A missing decimal point can be read as microns: X10 may mean 0.010 mm on some controls. Always write X10.0.
Controller compatibility
G21 follows the ISO/Fanuc dialect used by Fanuc, Haas, Brother, Doosan, Hurco (ISO mode), Mazak (EIA/ISO mode), Okuma (G-code mode) and Siemens in ISO dialect mode. Parameters, option packages and builder-specific behaviour can differ, so confirm the details in your machine's programming manual before running a new program.