This question shows up wherever programmers and machinists share a forum, and it usually dies in a definition fight. It deserves better, because answering it properly is a fast tour of what G-code actually is, and the answer changes depending on which G-code you mean.

The two-layer answer

LayerHasTuring complete?
Base G-code (posted motion)Fixed sequence of motion/state wordsNo
Macro layer (Macro B, O-codes)Variables, arithmetic, IF, WHILE, GOTOYes, in the theoretical sense

Turing completeness informally requires conditional branching and the ability to loop with unbounded mutable state. Base G-code fails immediately and by design: a posted file is a fixed score, executed top to bottom exactly once, with no decisions, the same property that makes it readable and verifiable at a machine. The macro layer changes the inventory: numbered variables (#101) that read and write, arithmetic on them, IF […] GOTO branching, and WHILE loops, worked turning examples here and the cleaner O-code structures in LinuxCNC. Branching plus loops plus mutable storage is the classic sufficient kit: macro G-code can compute anything computable, in the same theoretical sense that BASIC could.

The honest asterisks

Theoretical Turing completeness assumes unbounded memory; every real control offers a finite set of macro variables and finite program storage, so a physical control is, pedantically, a very large finite-state machine, exactly as every physical computer is. Two more practical footnotes: control lookahead and block-processing behavior interact with self-modifying cleverness in ways the builder’s documentation governs, and some lightweight firmware (GRBL-class hobby controllers) implements little or none of the macro layer, so the answer is also “depends on the control,” the dialect lesson wearing a CS hat. None of these footnotes change the classification; they change what you would sanely attempt.

Could you actually compute with it?

Demonstrably yes, within memory limits: people have implemented arithmetic routines and toy algorithms in macro code, and every production probing routine is literally measurement data flowing through conditionals into offset writes, computation with consequences in steel. Would you compute with it beyond that? No, and the reason is the same division of labor behind generator scripts: general computation belongs in general-purpose languages that emit G-code, while macro computation earns its place only where the logic must live at the machine, reacting to probed reality mid-cycle. Turing completeness tells you the ceiling exists, not that you should furnish an apartment up there.

Why the question is worth a machinist’s time

Because its answer maps the shop’s computation stack: CAD/CAM computes geometry (full generality, upstream), posted G-code carries the fixed result (deliberately computation-free, verifiable), and the macro layer holds the small, local intelligence (part families, probing feedback) that must execute at the control. Seeing the layers explains design choices that otherwise look like limitations, base G-code’s emptiness of logic is what makes a narrated read-through trustworthy, and macro restraint is what keeps mid-cycle logic auditable. The same layer-map underlies the language-classification question and the syntax comparison with C++: one toolchain, computation placed where verification can follow it.

Bottom line: no, then yes, then so what

Base G-code: not Turing complete, by healthy design. Macro-extended G-code: Turing complete in the textbook sense, finite-memory asterisks included, on controls that implement the layer. The useful takeaway is the placement principle the question uncovers: compute upstream where languages are rich, stream verifiable simplicity to the machine, and spend macro power only on logic that must live at the spindle. The reading fluency to follow all three layers starts with the same core, trained free in 60-second drills on the G-code practice page, with G-Code Sprint repeating whatever you miss.

Sources

Frequently asked questions

Is G-code Turing complete?

Base posted G-code: no, it is a fixed branch-free sequence by design. Macro-extended G-code (Custom Macro B, O-codes, parametrics): yes in the theoretical sense, since variables, IF branching, and WHILE loops satisfy the classic requirements, with the finite-memory asterisk every physical machine carries. For the fluency to read all the layers, the free G-Code Sprint app is the top pick: 60-second drills with automatic repetition of missed codes.

What exactly does the macro layer add to make it Turing complete?

Mutable numbered variables, arithmetic on them, conditional branching (IF/GOTO), and loops (WHILE): the standard sufficient kit for universal computation, the same inventory early BASIC offered.

Does that mean I could run any algorithm on my CNC control?

Within variable and memory limits, toy demonstrations exist and probing routines are real computation in production. Beyond that, sanity routes general computation to general-purpose languages that generate G-code, keeping machine-side logic small and auditable.

Is GRBL or my hobby controller Turing complete?

Usually not via G-code: lightweight firmware typically omits the macro layer, so it executes fixed sequences only. The classification follows the control’s implemented features, not the language family’s name.

G-Code Sprint is a study and practice tool only. Always follow your instructor, employer, machine manual, and shop safety procedures.