Kerfwise G-code Inspector
Check G-code: cutting and rapid length, machining time, bounds, tools, warnings, preview.
Try an example: Hand-checkable square with one R10 corner arc (G21, G3 with I/J) · Inch program: G83 peck drilling, two tools, R-format arcs, acceleration 500 mm/s² · Kerfwise LinuxCNC program for one sheet (drilling + profiles)
How it works
Reads a CNC G-code program (GRBL, LinuxCNC, Fanuc-style, most CAM posts) and measures the rapid and cutting path, the machining time with an optional acceleration and cornering model, the X/Y/Z bounds and Z range, statistics per tool and the feeds and spindle speeds used. It warns about missing units, missing feed rates, arcs whose radius does not match, sideways rapids below Z0 and other common mistakes, and draws a top-view toolpath preview.
- Each line is read like an RS-274/NGC controller: comments in ( ) and after ; are removed, modal state (motion G0–G3 and canned cycles, plane G17/G18/G19, units G20/G21, distance mode G90/G91, arc centre mode G90.1/G91.1, feed mode G93/G94/G95, retract G98/G99, F, S, T) carries over from line to line. Inch programs are converted to mm.
- Arcs: the centre comes from I/J/K (relative to the start unless G90.1) or from R (negative R = more than 180°). The length is the swept angle × radius, combined with the linear axis for helical arcs. If start and end radius differ by more than 0.002 mm (or 0.1 %), a warning is raised, as many controllers stop there.
- Canned cycles G81/G82/G83/G73/G85/G89 are expanded into their rapid and feed moves (G83 retracts to R after each peck and rapids back to 0.254 mm above the last depth).
- Time without acceleration = feed moves ÷ feed + rapids ÷ rapid rate + dwells (G4 P seconds, Fanuc G4 X seconds) + tool changes + program stops. With an acceleration, every move follows a trapezoid profile with GRBL-style look-ahead: corner speed from the junction deviation, arcs limited to √(a × r), full stops at dwells, tool changes, spindle changes and pauses.
- Bounds cover every move (rapids included); cutting bounds cover the feed moves only. Statistics are split per tool loaded with M6 (or with T alone in programs without M6).
An estimate, not a machine simulation: controller look-ahead, feed overrides, tool-change routines and macros differ. Always dry-run a program above the material first.
Sources
- The NIST RS274NGC Interpreter — Version 3 (Kramer, Proctor, Messina) (NIST)
- LinuxCNC G-code reference: G0–G3 (I/J/K and R arcs), G17–G19, G20/G21, G90/G91, G90.1/G91.1, G93–G95, G4, G73/G81–G89 canned cycles, G98/G99 (LinuxCNC)
- Grbl v1.1 configuration: $11 junction deviation, $120–$122 acceleration (look-ahead planner) (gnea/grbl wiki)
Part of Kerfwise
-
Kerfwise Cabinet & furniture CAD
Design cabinets and furniture, get cut lists, optimised sheet layouts, costs and drawings.
Related tools
- Kerfwise CNC G-code Generator – Nest parts and get CNC router G-code: compensated profiles, tabs, ramps, drilling cycles, time.
- Kerfwise CNC Feeds & Speeds Calculator – CNC router rpm, feed, chip load with chip thinning, removal rate and spindle power.
How to use the Kerfwise G-code Inspector
Check a CNC G-code program for cutting and rapid length, machining time with acceleration, bounds, Z range, per-tool statistics and common mistakes.
What it is for
A G-code file looks harmless until the machine dives into the spoilboard or an arc throws an error halfway through a sheet. The inspector reads the program the way a controller does and tells you what it will do before you press start.
Paste a program or upload an .nc, .ngc, .gcode or .tap file. The tool follows the modal state line by line: G0/G1 moves, G2/G3 arcs with I/J/K centres or R radius, planes G17/G18/G19, inches or millimetres, absolute or incremental mode, feed modes, dwells and canned drilling cycles. It reports the cutting and rapid path, the machining time, the bounds and Z range, statistics per tool and warnings, and it draws a top view of the toolpaths.
Macros, parameters and subprograms are skipped with a warning.
Worked example
The first example is a hand-checkable outline: plunge to Z−1 at 300 mm/min, then three straight sides and one R10 corner arc at 1200 mm/min. The inspector reports:
14 lines in mm: 162 mm cutting and 11 mm rapid, about 9 s, 1 tool, 0 warnings.
You can check that by hand. The plunge is 6 mm, the sides are 40 + 30 + 30 + 40 mm and the quarter arc is 5π ≈ 15.7 mm, so the cutting path is 161.7 mm. The plunge takes 1.2 s and the rest about 7.8 s.
The second example is an inch program with two tools, G83 peck drilling and R-format arcs, with an acceleration of 500 mm/s². It reads 151 mm of cutting and 566 mm of rapids. The time is 1 min 13 s with acceleration against 1 min 05 s without, and 40 s of that is the two tool changes.
A broken program shows the warnings. Five lines without G21, G90 or a spindle start and with a deliberately wrong arc produced five warnings, among them "Line 3: the arc radius differs between start (4 mm) and end (6 mm)" and a sideways rapid below Z0.
How to read the result
- Machining time: feed moves at their feed, rapids at your rapid rate, plus dwells, tool changes (M6) and program stops (M0/M1).
- Acceleration: with a value, every move speeds up and slows down and corners are taken at the GRBL junction-deviation speed. Short, zig-zag toolpaths gain the most time.
- Bounds: all moves including rapids, and the cutting moves alone. Compare them with your sheet and your machine's travel.
- Per tool: cutting and rapid length, cutting time, arcs, lowest Z and highest feed for each tool.
- Warnings and notes: warnings point to real problems. Notes, such as an unknown G28 home position, are just worth knowing.
Tips and common mistakes
- Set Start Z to where the tool actually is when the program starts, often the safe height. Otherwise the first move is counted from Z0.
- Programs without G20 or G21 run in whatever units the controller last used; the inspector assumes millimetres and warns.
- An arc radius warning usually means a post-processor rounded the coordinates too hard. Many controllers stop on it.
- A sideways rapid below Z0 is only a crash if Z0 is the material top. With Z0 on the spoilboard, ignore it.
- In Kerfwise, the CNC view shows this report for the generated program, and Check a G-code file… inspects any other file locally.
FAQ
Why is the time different from my controller's estimate?
Controllers plan acceleration per axis and apply overrides. Enter your machine's acceleration for a closer estimate.
Which dialects does it read?
GRBL, LinuxCNC and Fanuc-style programs, plus most CAM posts that stick to standard RS-274 codes. Line numbers, % lines and comments in parentheses or after ; are fine.
Does it understand cutter compensation?
It measures the programmed path and adds a note when G41 or G42 is active. The real compensated path is offset by the tool radius.
Is my file uploaded anywhere?
On the website the file goes to the tool like any other input. In the Kerfwise app the check runs completely in your browser.
Guide last updated:
For scripts and AI agents
- JSON API:
POST https://kerfwisegcodeinspector.usefulweb.site/api/v1/calculate(same calculation as this page) - Interface description: OpenAPI 3.1 · AI guide: llms.txt
- MCP server (Streamable HTTP):
https://kerfwisegcodeinspector.usefulweb.site/mcp· tool namekerfwise_gcode_inspector
Example request
curl -s -X POST https://kerfwisegcodeinspector.usefulweb.site/api/v1/calculate \
-H 'content-type: application/json' \
-d '{"gcode":"(40 x 40 mm pocket outline with one R10 corner)\nG21 G90 G17\nG0 Z5\nG0 X0 Y0\nS12000 M3\nG1 Z-1 F300\nG1 X40 F1200\nG1 Y30\nG3 X30 Y40 I-10 J0\nG1 X0\nG1 Y0\nG0 Z5\nM5\nM30"}'