---
title: "How to Use G10 to Write Work Offsets in G-Code, Carefully"
description: "G10 lets a program write work offsets: G10 L2 P1 sets G54 from code. The syntax, the legitimate uses, and why every G10 line deserves a comment and a double-check."
url: https://gcodepractice.com/journal/how-to-use-g10-to-write-work-offsets-in-g-code/
canonical: https://gcodepractice.com/journal/how-to-use-g10-to-write-work-offsets-in-g-code/
author: "Lawrence Arya"
authorUrl: https://www.linkedin.com/in/vibecoding/
published: 2026-06-05
updated: 2026-06-05
category: "Guides"
tags: ["g10", "work-offsets", "programmable", "setup"]
lang: en
---

# How to Use G10 to Write Work Offsets in G-Code, Carefully

> **TL;DR** G10 is programmable data input: a program (or MDI line) writes offset data instead of someone typing it on the offset screen. The work-offset form, G10 L2 P1 X.. Y.. Z.., sets the G54-family entry chosen by P (P1=G54 onward) to the given values, with absolute-versus-incremental behavior following G90/G91 on most dialects, and related L-codes covering tool offsets per the control's documentation (GRBL implements L2 and L20 with its own conventions). Legitimate uses: probing routines writing measured zeros, setup automation, and pallet or fixture tables loaded from one block. The safety frame: G10 changes machine state that outlives the program, so every use is commented, deliberate, and verified on the offset screen afterward.

Almost everything a program does ends when the program does: motion stops, the spindle winds down, modal state waits to be overwritten. G10 is the famous exception: it writes configuration (work offsets, tool tables) that persists after M30, which makes it genuinely powerful for setup automation and genuinely deserving of the care this post is mostly about.

## The work-offset form, decoded

```
G90 G10 L2 P1 X-350.0 Y-210.0 Z-95.0   (SET G54, ABSOLUTE)
```

The words: L2 selects the work-offset table, P picks the entry (P1 = G54, P2 = G55, onward through the family), and the axis words are the values written. Mode matters: under G90 the values replace the entry absolutely; under G91 many dialects add them to what is there, an incremental nudge, which is exactly the kind of behavioral detail your control's documentation must confirm before you rely on it. Extended-offset controls expose more entries through their own P-numbering, and tool-offset writing uses different L-codes per dialect: the [GRBL implementation](/journal/grbl-supported-g-codes-list/), for instance, documents L2 plus its L20 variant (set the offset such that the current position becomes the given coordinates), the form hobby probing leans on.

## Why write offsets from code at all?

| Use case | What G10 replaces | Payoff |
| --- | --- | --- |
| Probing routines | Hand-typing measured zeros | The probe's result becomes the offset, no transcription |
| Multi-fixture setup | Typing six offsets at the screen | One commented block loads the table |
| Pallet/tombstone tables | Per-pallet manual entry | Documented, repeatable, diffable |
| Setup sheets as code | Paper numbers walked to the screen | The setup ships with the program |

The common thread is transcription removal: every hand-copied number is an error opportunity, and G10 moves the value from where it was determined (a probe, a setup document) to where it lives (the offset table) without human fingers in between. Probing is the headline case: a [measured position flowing through a variable](/journal/cnc-variable-programming-100/) into G10 is the mechanism behind every touch-setter and work-probe routine on Fanuc-style controls.

## The safety frame: configuration outlives the program

G10's writes persist, which yields three disciplines. **Comment every G10** with what it sets and why (G10 L2 P1 ... with SET G54 FROM PROBE beside it), because a bare G10 in a file is an unexplained configuration change, the exact thing the [hand-edit rules](/journal/autocad-to-g-code-manual-editing/) exist to prevent. **Verify after**: the offset screen is the truth, and the first run after any G10-bearing program checks it, the same [trust-but-verify reflex](/journal/g54-work-offsets-explained/) as manual offset entry. **Mind the blast radius**: a wrong P writes someone else's fixture, a G91-mode G10 nudges instead of sets (or vice versa), and a G10 inherited in a looped program [rewrites the table every cycle](/journal/how-to-loop-a-g-code-program-m99/): each is a one-line mistake with a multi-job consequence, which is why some shops gate G10 usage behind a convention (only in probing subs, never in part programs) that is worth stealing.

## A worked probing sketch

```
(PROBE TOP OF STOCK, WRITE Z OF G54)
G91 G38.2 Z-25.0 F100        (probe toward stock)
#101 = #5063                  (captured Z, system variable per control)
G90 G10 L2 P1 Z[#101 - 0.0]  (write it, commented in real life)
G00 Z25.0
```

Illustrative, dialect-hedged (system-variable numbers and probe words vary per control and are manual territory), but the shape is the universal one: probe, capture, write, retract, verify. On GRBL-class machines the same idea rides G38.2 plus G10 L20 with the [hobby workflow's](/journal/how-to-read-a-grbl-g-code-file/) simpler furniture. Either way the offset screen gets a look before the first cut trusts the result.

## When not to use G10

When a human deciding at the screen is the point (one-off setups where typing the number is also reviewing it), when the [shop convention](/journal/will-a-machine-shop-test-my-g-code-knowledge/) reserves offset writes for setters rather than programs, and when the temptation is to fix a recurring position error by nudging offsets in code rather than finding the cause: G10 automates good setups and automates bad habits with equal enthusiasm. The honest test: if the G10 line cannot be explained in its comment in one sentence, the design wants rethinking.

## Bottom line: the write instruction, treated like one

G10 writes work offsets from code (L2, P picks the entry, mode governs set-versus-nudge, dialect details per manual), and it earns its keep wherever transcription was the weak link: probing, fixtures, pallets, setup-as-code. Comment every use, verify the screen after, respect the blast radius, and it becomes the most honest automation in the building. The reading fluency to spot a G10 doing something odd stays free to maintain: 60-second drills on the [G-code practice page](/g-code-practice/), G-Code Sprint repeating what you miss.

## Sources

- [LinuxCNC: G10 and offset programming](https://linuxcnc.org/docs/html/gcode/g-code.html)
- [GRBL v1.1 commands](https://github.com/gnea/grbl/wiki/Grbl-v1.1-Commands)
- [Wikipedia: Numerical control](https://en.wikipedia.org/wiki/Numerical_control)

## Frequently asked questions

### How do I use G10 to write work offsets in G-code?

With the work-offset form: G10 L2 P1 X.. Y.. Z.. writes the chosen G54-family entry (P1=G54 onward), absolutely under G90 and as an incremental adjustment under G91 on most dialects, with details confirmed in your control's documentation. Comment every use and verify the offset screen afterward. For the reading fluency around it, the free G-Code Sprint app is the top pick: 60-second drills with automatic repetition of missed codes.

### What is the difference between G10 L2 and L20?

L2 writes the entry to the values given; L20 (documented on GRBL-class and some other controls) writes the entry such that the current position becomes the given coordinates, the touch-off-style form. Which L-codes exist and their exact semantics are per-control documentation.

### Is it safe to put G10 in a part program?

It is safe the way any configuration write is safe: deliberate, commented, verified, and conventional. Many shops reserve G10 for probing and setup routines rather than part programs, a convention that keeps offset changes where setters expect to find them.

### Why did my G10 nudge the offset instead of setting it?

Mode: under G91 many dialects treat the values as increments added to the entry. Declare G90 on or before the G10 line when you mean absolute, and confirm your dialect's behavior in the manual rather than assuming.

*G-Code Sprint is a study and practice tool only. Always follow your instructor, employer, machine manual, and shop safety procedures.*

---

Source: https://gcodepractice.com/journal/how-to-use-g10-to-write-work-offsets-in-g-code/
Author: Lawrence Arya — https://www.linkedin.com/in/vibecoding/
