G-Code Shifter

Shift all X, Y, and Z coordinates in a program by an incremental value. Positive values move the tool path in the positive direction.

Shift Amounts
The parser automatically ignores coordinates hidden inside comments (e.g. (X0.0 Y0.0)).
Original G-Code
Click or drag G-code file here Supports .nc, .txt, .gcode
Shifted Result

How the G-Code XYZ Shifter Works

The shifter adds a fixed amount to the X, Y and Z positions in a program, which moves the whole toolpath without changing its shape. A positive shift moves the path in the positive direction of that axis.

Typical uses are moving a job to a different place on the stock, laying out several copies of a part on one plate, or correcting a program that was posted from the wrong origin. The page reads the program line by line and keeps track of the modes that decide what a number means: absolute (G90) or incremental (G91) positioning, and whether a drilling cycle is active. Only absolute part positions are moved. Distances, reference positions, offsets and dwell times are left as they were.

The program is assumed to start in G90. Code written without spaces, such as G1X2.Y3., is read the same way as spaced code.

How It Works

What Changes (in G90)
X new = X + X shift
Y new = Y + Y shift
Z new = Z + Z shift
Cycle R new = R + Z shift
The R plane of an active canned cycle (G73, G74, G76, G81 to G89) moves with the Z shift, so the clearance above the part stays the same. A cycle stays active until G80 or a G00 to G03 move. A shifted number keeps its decimal places, limited to between 3 and 5; one written without a decimal point comes back with 4. An axis with a shift of 0 is left exactly as written.
What Is Never Changed
Any line while G91 is active
Lines with G04, G10, G28, G30, G52, G53 or G92
I, J, K and arc R; F, S, T, M, P, Q
Comments in ( ) or after ;
Incremental moves are distances, so shifting them would change their length. Reference returns, machine coordinates, offset settings and dwells are not part positions. I and J are measured from the arc start on most controls, so they move with the arc. Everything from an opening bracket (or a semicolon) to the end of the line is treated as comment.

Worked Examples

Shift X +1.5, Y −0.25, Z 0
Original
G90 G54 G17
G0 X0.5 Y0.5 Z0.1 (START X0.5)
G1 Z-0.05 F10.
G1 X2.25 Y0.5 F20.
G2 X2.75 Y1. I0 J0.5
G0 Z1.
Shifted result
G90 G54 G17
G0 X2.000 Y0.250 Z0.1 (START X0.5)
G1 Z-0.05 F10.
G1 X3.750 Y0.250 F20.
G2 X4.250 Y0.750 I0 J0.5
G0 Z1.
  • X0.5 + 1.5 = X2.000 and Y1. − 0.25 = Y0.750.
  • Z is not shifted, so Z0.1 and Z-0.05 keep their original text. The arc I0 J0.5 and the comment are unchanged.
Drilling with a Z shift of +0.5
Original
G90 G54 G17
G0 X1. Y1. Z0.5
G81 X1. Y1. Z-0.25 R0.1 F5.
X2.
G80
G91 G28 Z0.
Shifted result
G90 G54 G17
G0 X1. Y1. Z1.000
G81 X1. Y1. Z0.250 R0.600 F5.
X2.
G80
G91 G28 Z0.
  • The hole depth and the R plane both rise by 0.5, so the tool still rapids to 0.1 above the new top of the part.
  • G91 G28 Z0. is a reference return in incremental mode, so it is not touched.

Dwell lines such as G04 X1.0, G53 machine moves and G10 or G92 settings come through unchanged in the same way. Enter the same values above and you will get the same output.

Tips for Using the Results

  • Consider a work offset first. Moving the G54 zero, or a G52 local shift on controls that support it, moves the program without editing it and is easy to undo. Use the shifter when the file itself has to change.
  • Check incremental sections. Lines in G91 are left alone, which is right for moves relative to a shifted point. If a G91 section starts from a position that is not in the program, such as a subprogram called from somewhere else, check where it ends up.
  • Look at the start of the program. The page assumes G90 until it sees G91. If your program relies on the control already being in G91, add G90 or G91 at the top before shifting.
  • Combine with the mirror. To reflect a part about a line other than zero, mirror it with the G-Code Mirror and then shift it by twice the line position.
  • Backplot the result. Load it into the G-Code 3D Viewer and check the extremes against your machine travel, vice jaws and clamps.

Frequently Asked Questions

They are left unchanged. An incremental move is a distance from the current position, so once the absolute moves before it have been shifted it already lands in the right place. The page switches between absolute and incremental handling each time it sees G90 or G91.

No. Any line containing G04, G10, G28, G30, G52, G53 or G92 is passed through exactly as written, because its X, Y and Z values are reference positions, machine coordinates, offset settings or dwell times rather than positions on the part.

Yes, in absolute mode. While a canned cycle such as G81 or G83 is active, the R value is moved by the Z shift along with the hole depth, so the clearance above the part does not change. Q and P are left alone, and a cycle programmed in G91 is not changed.

It leaves I, J and K alone, which is correct on most controls because they are measured from the start of the arc and move with it. An arc R value is a radius and is never changed. Only a control set to absolute arc centres (G90.1) would need I and J shifted as well.

Changing the work offset is usually safer, because the proven program stays as it was and the change is easy to undo. Shifting the code makes sense when you want several copies of a part at different positions in one program, or when you cannot change the offset on the machine that will run the file.

Always backplot the shifted program, check it against your machine travel and fixturing, and prove it out with single block and reduced rapids before cutting.