# LinuxCNC G21 Units: millimeters

Instructions · `G21` · verification: source checked

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.

## Specification

| Property | Value |
|---|---|
| Language | gcode |
| Code | G21 |
| Group | Units |
| Syntax | G21 |
| Dialect | LinuxCNC |

## Connected

- Related: [LinuxCNC M72](https://machineschema.com/instruction/mcode-m72.md)

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

## Sources

1. [G-Codes](https://linuxcnc.org/docs/html/gcode/g-code.html#gcode:g20-g21) (accessed 2026-10-26)

---

Source page: https://machineschema.com/instruction/gcode-g21  
JSON: https://machineschema.com/instruction/gcode-g21.json  
License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Cite Machine Schema and the original sources.
