G-Code Mirror
Invert toolpaths across an axis. This tool automatically inverts coordinates, updates I/J/K arc vectors, and smartly swaps G02/G03 directions and G41/G42 cutter compensation to maintain correct geometry.
Original G-Code
Mirrored Result
How the G-Code Mirror Works
The mirror reverses the sign of every coordinate on the axes you choose, so the toolpath is reflected about program zero. Where a reflection needs it, it also swaps the arc direction and cutter compensation codes, so the mirrored program still cuts a proper part.
Mirroring is the quick way to make the opposite-hand version of a part, such as a left and right bracket or a pair of handed mounting plates, without going back to CAM. The reflection line is always zero on the axis you mirror. Mirroring X reflects the path about X0 of the active work offset, so a point programmed at X2.0 ends up at X-2.0. Make sure your part zero sits on the line you want to reflect about, or move the result afterwards.
The page works on the text of the program one line at a time. It does not simulate the program or track modal states, so it cannot tell a coordinate from a dwell time or an offset value. Read the limits below before you run anything it produces.
How It Works
Worked Examples
G90 G17 G54 G0 X1.0 Y0.5 G41 D1 G1 X2.0 Y0.5 F20. G3 X2.5 Y1.0 I0 J0.5 G1 X2.5 Y2.0 (TOP X2.5) G40 G1 X3. Y2.25
G90 G17 G54 G0 X-1.000 Y0.5 G42 D1 G1 X-2.000 Y0.5 F20. G02 X-2.500 Y1.0 I0.0000 J0.5 G1 X-2.500 Y2.0 (TOP X2.5) G40 G1 X-3.000 Y2.25
- G41 became G42 and G3 became G02 (the page writes the two-digit form).
- X1.0 became X-1.000 because 3 decimals is the minimum. I0 had no decimal point, so it is written I0.0000.
- Y values and the comment (TOP X2.5) are unchanged.
Run the same program with both Mirror X and Mirror Y switched on and every X, Y, I and J value changes sign, but G41 and G3 stay as they are, because the result is a 180° rotation rather than a reflection.
Tips for Using the Results
- Expect climb milling to become conventional. A single-axis mirror makes the tool travel the other way round the profile. Swapping G41 and G42 keeps the cutter on the correct side of the line, but a climb-milled profile is now cut conventionally. Expect a different finish and tool load, or reverse the path in CAM if you need climb milling.
- Mirror about another line. The page always reflects about zero. To reflect about X50, mirror X and then add 100 (twice the line position) with the G-Code XYZ Shifter.
- Check lines that are not moves. Every X, Y, Z, I, J and K value is negated whatever it means. A dwell such as G04 X1.5 becomes G04 X-1.500, and values on G10, G52, G92, G28 or G53 lines change sign too. Drilling-cycle R and Q values are not touched, so mirroring Z leaves the R plane where it was. Edit these lines by hand.
- Do not mirror thread milling paths. Reversing the arc direction of a helical path changes the hand of the thread, so a right-hand thread comes out left-hand. Regenerate it with the Thread Milling Generator instead.
- Backplot before cutting. Load the result into the G-Code 3D Viewer, then prove it out on the machine with single block and reduced rapids.
Frequently Asked Questions
Mirrored programs must be checked before cutting. Backplot the result, check cutter compensation, the cutting direction and any dwell or offset lines, and prove the program out with single block and reduced rapids.