Complete Guide to Comments in G Code

a cnc machine running with g code overlaid

Comments in CNC g code are portions of the program that are ignored by the CNC controller and/or help the machine operator understand the program.

There are many different machine manufacturers and they can each have their own format for handling and identifying comments. In other words, what works on one machine may not work on another.

When in doubt try to find a manual or research your specific brand of CNC. We have outlined some of the most common CNC manufacturers and how they call out comments in the table below.

You can see that the two most common ways to identify a comment are by enclosing it in parentheses () or placing a semicolon symbol ; before the comment.

How to insert a comment into a g code program

The table below lists the symbol or character that is used to identify g code comments on a specific line of the program.

Take note that when parentheses () are used, everything between the open and closed parentheses will be ignored.

When the semicolon ; is used, all code after the semicolon on that line will be ignored and treated as a comment. Placing a semicolon inside a parentheses will not make the machine ignore the rest of the line, only what is inside the parentheses in this case will be ignored.

Remember, there are dozens or possibly hundreds of machine tool manufacturers and some may not adhere to these rules but this guidance will work for the majority of machines.

Machine Control Manufacturer

G Code Comment Character











Sinumerik (Siemens)




What should be included in a g code comment?

Comments can include anything that can help to operator or setup person to better understand how the program is operating.

Placing comments at key moments in the program can be a great way to help an operator. Letting them know if they need to perform an action or if the program is about to start a new operation (switching from roughing to finishing or starting to drill a set of holes) can be extremely helpful.

The best practice is to be brief but provide enough info. You don’t want to write a book and clutter up the program, but too little information can leave a person guessing or assuming what is happening in the program.

Creating good comments can help someone who isn’t highly trained in reading g code but they can also help you when you go to troubleshoot the program or try to edit or improve it later on down the road.

Where should you put comments in your CNC program?

In general, g code comments should be placed at the end of the program line to describe the current action. Some machines allow comments, specifically ones in parentheses (), to be added in the middle of the line.

I recommend avoiding this practice as much as possible. It can cause issues with some machines. Sticking with a semicolon or parentheses at the end of the line will help ensure your program is the most compatible with a wider assortment of machines.

As we noted above, it is also a good idea to include comments at the start of a new section of your program.

Tooling descriptions, offset information and descriptions of the operations being performed are all great info to include in the comments at the start of a new section.

A block of comments at the start of your program is a welcome addition that many CAM programs will automatically insert with information such as the program creators name, a date or revision of the program and miscellaneous other information.

When should you use comments in your g code?

Comments add to the size of the CNC program (not as much of an issue with newer machines) and also clutter up the code.

Use them sparingly and in the important places. You don’t need to comment ever move.

Comments work great at the start of program sections to help operators know what to expect or what is expected of them.

Leave a Comment