Skip to content

G-code checker for CNC milling: what is wrong before you run it

Paste a milling program and the checker follows it line by line to find missing units, work zero and spindle, and checks spindle speed and feed per tooth against rules. It runs in your browser.

Opens without an account 3 times a day. A free account removes the limit.

What a G-code checker is and what it finds

A G-code checker looks through a program for defects. The CNC program analyser from EduFacturing is a free online tool that reads milling G-code and tracks the machine state line by line: units, positioning mode, work zero, spindle, coolant, feed and position. That way it finds defects that cannot be seen on a single line, because most commands stay in force until something changes them.

There are 13 kinds of findings, ordered by severity. Two checks are numeric: spindle speed and feed per tooth (how many mm the cutter advances per tooth) are checked against rules from the rules core, and each such finding carries the rule ID and its citation.

G-code checker: fields for material, diameter, teeth and safe Z, a sample program and findings: 0 errors, 1 warning, 1 note
G-code checker: fields for material, diameter, teeth and safe Z, a sample program and findings: 0 errors, 1 warning, 1 note

Errors in a CNC program: what you get

Follows the state line by line

A line X50 with no G-code continues the last move, so the check carries the state through the whole program. It counts moves and the rapid and cutting path.

Finds defects in the program

Errors are a program with neither G21 nor G20, neither G90 nor G91, a move before work zero, cutting with the spindle stopped, cutting without a feed and a rapid below the safe height. A missing M30 or M2 and a tool change without retracting are warnings.

Checks speed and feed per tooth

Spindle speed is compared with the cutting speed for the material, and feed per tooth is derived from the program. If there is no rule for the material, the check is declared not done.

Says what it did not follow

Cycles G81-G89, compensation G41, G42 and G43, rotation G68 and subprograms M98 and M99 are marked as not followed, and so are lines that do not look like G-code.

When to check G-code before the machine

A program is checked before it reaches the machine.

  • A file from another post processor

    Paste the program and see whether units, zero and spindle are declared.

  • A CAM programmer

    Check what comes out of the post processor: units, program end, a feed before cutting.

  • A CNC student

    See from the findings that cutting with the spindle stopped or a move without zero depends on the lines before it.

  • A shop without a process engineer at hand

    Check spindle speed and feed per tooth against rules, not from memory.

How G-code is checked: state, speed, feed

There are two kinds of checks: structural ones, which need no rule, and numeric ones, which cite a rule from the rules core.

  1. Reading

    Each line is split into words of a letter and a number, and comments are dropped. G and M codes change the state, while S, F and T add to it.

The formulas and ranges in the tool
Applies toFormulaMeaning
Spindle speedn = vc · 1000 / (π · D)vc in m/min, D in mm; vc limits: aluminium 200-500, mild steel 80-150, brass 150-300, titanium 20-60
Feed per toothfz = F / (S · z)F the highest feed, S the highest speed, z teeth; limits: aluminium 0.05-0.2, mild steel 0.02-0.12 mm/tooth

Numbers come from a rule, not from memory

  • Numbers come from a rule, not from memory

    A finding shows the rule ID. Without a rule the check is declared not done, not run on a remembered number.

  • It says what it does not know

    Codes it did not follow and numeric checks it did not run are listed, instead of being assumed harmless.

What it does not do

Zero findings does not mean a good program. The analysis does not unroll cycles, does not interpolate arcs (an arc’s length is counted as a straight line between its ends), does not follow subprograms and does not know the shape of the part or the fixture: it can say a rapid drops below the safe height, not that it will hit the vice.

The checks for a rapid below the safe height and for a tool change work only when a safe Z is entered. Speed is checked for four materials and feed per tooth for two; for 316 stainless the rule is a table by tool material and is not used. The path leaves out the first move on each axis. Inches are not converted to millimetres: a program with G20 is compared with the ranges in mm. T and M6 on one line do not record the tool in the statistics. It is built for milling G-code.

Questions about the G-code check

How to check G-code for errors in a milling program?

Paste the program and enter the material, diameter, teeth and safe Z. The checker follows it line by line and shows the findings by severity: errors, warnings and notes.

What does the G-code checker find?

13 kinds in all, for milling G-code. Errors are 6 kinds (units, positioning, zero, spindle, feed, a rapid below the safe height), warnings 4 (program end, tool change without retracting, feed per tooth, speed above the range) and notes 4 (coolant with the spindle stopped, codes not followed, lines that do not look like G-code, speed below the range). Speed is one kind.

Why is it an error when both G21 and G20 are missing, and not a note?

A program with neither is formally valid and will start with the units left in the control from the previous program. The same code can make the part or make it 25.4 times larger. The same goes for a program with neither G90 nor G91.

How is spindle speed checked?

By n = vc · 1000 / (π · D), against the cutting speed range for the material. For 10 mm aluminium (200-500 m/min) that is 6366 to 15915 min⁻¹. Above the range is a warning, below it a note.

Where does feed per tooth come from?

From the program itself: fz = F / (S · z), with the highest F and the highest speed. The sample program (F400, S3000, 3 teeth) gives 0.044 mm/tooth against a range of 0.05-0.2 for aluminium: a warning.

Does zero findings mean the program is safe?

No. It means zero by the tool’s checks. Cycles, arcs and subprograms are not unrolled, and the shape of the part and the fixture are unknown.

Is it free, and do I need an account?

Yes, it is free. Without an account the tool opens 3 times a day. A free account removes the limit.

The G-code checker is free. Pro opens the rest

Pro costs 15 EUR a month and opens 45 Pro tools.

Check your program

Opens without an account 3 times a day. A free account removes the limit.