G21: Metric units
What G21 does
G21 makes the control read dimensions in millimetres and feeds in mm per minute or per revolution. Put it in the safety line at the start of the program so the unit never depends on what the last program left active.
| Type | G-code |
|---|---|
| Machine | Mill and lathe |
| Group | Units |
| Modal | Yes: stays active until replaced by another code from the same group |
G21 example
G21 Everything after this is in millimetres.
| Word | What it means here |
|---|---|
G21 | Metric units |
Codes people confuse with G21
| Code | What it does instead |
|---|---|
G20 | Inch units. Programs positions and feeds in inches. |
Other codes in the units group
Only one code from a modal group is active at a time. Programming any of these replaces G21.
G20Inch units
Meanings follow the common Fanuc-style standard that Haas, Okuma (EIA mode), Mitsubishi, LinuxCNC and most other controls share for this code. Options and parameters change details from machine to machine, so check the manual for your control.
Quick check: G21
-
What does
G21do? (Mill and lathe) -
Which code: Programs positions and feeds in millimetres.(Mill and lathe)
-
What does
G20do? (Mill and lathe)
Show the answers
- Programs positions and feeds in millimetres.
- G21
- Programs positions and feeds in inches.
Frequently asked questions
- What does G21 mean in CNC programming?
- Metric units. Programs positions and feeds in millimetres.
- Is G21 modal?
- Yes. G21 belongs to the units group and stays active until another code from that group is programmed.
- What is the difference between G21 and G20?
- G21 (metric units): programs positions and feeds in millimetres. G20 (inch units): programs positions and feeds in inches.
G-Code Sprint is an educational practice tool only. It is not a CNC simulator, machine controller, safety manual, or replacement for instruction. Always follow your instructor, employer, machine manual, and shop procedures.