G-Code Arc (I/J/K) Calculator

Generate G02/G03 I/J center-offset values from start, end, and radius

Takes an arc start point, end point, and radius and computes the incremental I and J center offsets needed for G02 and G03 CNC arc moves in the XY plane. Shows both possible arc solutions with sweep angle, marks the shorter one, and outputs a ready-to-paste G-code line. Runs in your browser. It runs free in your browser on Gera Tools, with nothing uploaded.

Last updated Source: Gera Tools

What are I and J in G-code arcs?

I and J are the incremental offsets from the arc start point to the arc center along the X and Y axes. Most controllers use incremental I and J by default in the XY plane, so I equals center X minus start X and J equals center Y minus start Y. This tool outputs them in that incremental form.

CNC controllers cut arcs with circular interpolation, and the trickiest part of hand-coding one is computing the I and J center offsets. This tool takes a start point, an end point, and a radius, computes the exact I and J values for both possible arc solutions, and outputs a ready-to-paste G02 or G03 line.

How it works — the geometry

The arc center must be equidistant from both endpoints, so it lies on the perpendicular bisector of the chord connecting them. Using the chord length and the radius, the distance from the chord midpoint to the center is found by Pythagoras, giving two centers — one on each side of the chord:

chord  = distance(start, end)
half   = chord / 2
a      = sqrt(radius² − half²)
center = midpoint ± a × (unit perpendicular to chord)
I      = center X − start X
J      = center Y − start Y

For each center the tool measures the swept angle in both directions to decide whether the minor arc is clockwise (G02) or counter-clockwise (G03), and marks the solution with the smaller sweep angle as the shorter arc.

Worked example

For a start point at (0, 0), end point at (10, 10), and radius 10:

  • Chord length = sqrt(10² + 10²) ≈ 14.14
  • Half-chord = 7.07; distance from midpoint to center = sqrt(10² − 7.07²) ≈ 7.07
  • Two centers: (10, 0) and (0, 10)

This gives two 90° arcs going in opposite directions:

SolutionCenterIJCodeSweep
Minor arc 1(10, 0)+10.00.0G0290°
Minor arc 2(0, 10)0.0+10.0G0390°

Both are 90° sweeps here (equal for a symmetric case). Choose the one whose bulge direction matches your intended toolpath, then copy the G-code line:

G02 X10.0 Y10.0 I10.0 J0.0 F200

Controller compatibility and edge cases

Incremental vs absolute I/J. The output uses incremental I and J (offset from the arc start to the center), which is the default on Fanuc, Haas, Mazak, LinuxCNC, and most other common controllers. If your machine uses absolute arc center mode (enabled by G90.1 on some Fanuc systems), use the printed center X/Y coordinates as I/J instead.

Radius too small error. An arc’s radius cannot be smaller than half the chord between the endpoints — the geometry has no solution. If you see this warning, either increase the radius or move the endpoints closer together.

Full circles. When start and end are the same point, I and J can define a full-circle arc. Most controllers require a full-circle move to be programmed as a single 360° arc with no endpoint specified, which this tool does not generate — use your CAM software for full circles.

G18 and G19 planes. This calculator targets the G17 XY plane, the default for most milling operations. For G18 (XZ plane) or G19 (YZ plane), the same geometry applies but the offset letters swap: I/K for G18 and J/K for G19. Verify your active plane modal before using the output.