G21 is a G-code command that selects millimeters as the length unit for a program. It is used in the preamble so subsequent length values are interpreted in millimeters.
Source checked3/3 values · 2026-10-26
Specification
1 source
Language
gcode
Code
G21
Group
Units
Syntax
G21
Dialect
LinuxCNC
Study notes
G20 selects inches; G21 selects millimeters.
The document recommends including units in the preamble of each G-code file.
When G21 is in effect, G96 constant surface speed uses meters per minute.
Can we use analytics cookies to see which specs people look up? Nothing is sold or used for ads.