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.

By cnccode · Updated
PropertyValue
CodeG21
FunctionMetric Input
Modal group06
TypeModal — stays active until replaced by another code of the same group
Used onMills and lathes
SyntaxG21

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

Format
G21

G21 example program

Example
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.

Frequently asked questions

Is G21 modal?
Yes. G21 belongs to modal group 06 and stays active until another code of that group is programmed.
What does G21 mean in CNC?
G21 means Metric Input. Interprets all following dimensions in millimetres (feeds in mm/min or mm/rev). On Siemens the equivalent is G71.
What is the difference between G21 and G20?
G21 is Metric Input, while G20 is Inch Input. See the G20 page for its syntax and examples.
Can I use G21 on a lathe?
Yes, G21 is used on both mills and lathes, although some parameters differ between them.