How to Estimate CNC Run Time from G-code (Without Running the Job)
Every shop has felt it: a customer asks "how much for this part?" and the honest answer is "let me run it and find out." But you can't tie up a machine to price a job you haven't won yet. So most of us fall back on gut feel — and gut feel is where margins quietly leak away.
The good news is that the G-code itself already contains almost everything you need to estimate run time. You just have to read it the way the controller does.
What's actually in the file
A .nc or .gcode program is a sequence of moves. Two kinds matter most for time:
- Rapid moves (G0): the machine repositioning at maximum traverse speed. No material is being removed.
- Feed moves (G1/G2/G3): cutting moves governed by the F (feedrate) word. This is where the real time goes.
If you walk the file line by line, track the current XYZ position, and sum the distance of each move, you can split the program into cut distance and rapid distance. Divide cut distance by the active feedrate and rapid distance by the machine's rapid rate, and you have a first-order time estimate.
Why the cut/rapid split matters
Two programs can have identical run times but very different cost profiles. A program that's 80% rapids is mostly air-cutting and repositioning — often a sign you can optimize lead-ins or reorder operations. A program that's 95% cutting is feed-bound, so the lever is feeds and speeds, not travel. Knowing the split tells you where to look before you ever touch the post.
Don't forget the envelope
While you're parsing, it's cheap to also track the minimum and maximum X, Y, and Z values. Those travel extents tell you the bounding box the program actually uses. That's a fast sanity check that the job fits your work envelope and fixturing before you load a single tool — and it catches a surprising number of bad posts and wrong-origin files.
The honest caveats
A line-by-line estimate won't perfectly match wall-clock time. It doesn't model acceleration/deceleration ramps, dwell, tool changes, or controller look-ahead. Treat it as a strong, consistent baseline — then apply your own shop multiplier from experience. Consistency is what makes quoting repeatable.
Skip the spreadsheet
You can absolutely build this parser yourself. Or you can drop a file into the CNC G-code Estimator, get run time, cut-vs-rapid distance, and XYZ extents in seconds, and get back to quoting. It's $5, one time, no account. If you quote machine time, it pays for itself on the first job.
View the tool →