
So you'd like to play with a G-code file (the numerical control programming language used by cnc machines) but don't have any sample G-code?
For starters, be sure to check out our Free G-code Tutorial. It's full of examples on a case-by-case basis for all the common G-code commands used by your machine tool.
Want completed programs?
No worries, here's a bunch of example G-code files you can try on your cnc machine to gain a better understanding of G-codes. Note that each specific machine may have its own dialect for G-codes. Be sure to check the example program before you run it in earnest to make sure it'll perform the right machining operations for your particular machine.
G-code Examples for Milling Machines

boomerangv4.ncc: 3D profiling job on a boomerang. View in CutViewer

Griffin Relief.ncc: 3D profiling job for a gryphon logo. View in CutViewer

HomeSwitchRearPanelEngrave.NCC: A control panel for my CNC electronics. View in CutViewer

SupportLogo.ncc: This G-code file is a CNCCookbook logo for my tooling rack. View in CutViewer
G-code Macro Examples

Warm Up Program: This G-code file runs your spindle and axes to warmup the CNC machine. It's a macro program (it uses #variables), so open it in a text editor or run it on a control that supports Fanuc-style macros.

Circle Cutter: Parameterized program to cut out a circle with optional drill in center. Like the warm-up program, it's a macro, so it needs a control that supports Fanuc-style macros.
Examples for Specific G-codes and M-codes
Our handy G-code reference lists have links to specific examples for all of the G-codes and M-codes.
Examples for 3D Printers
One thing you won't find here are G-code files for 3D printers. No print bed leveling, bed temperature, or other examples are available. That's because there are so many other resources for tracking down these other file formats needed by your 3D printer so you can get a perfect print.
How about a G-code Viewer? Check this out:
You can open any of the files above in CutViewer using the "View in CutViewer" links.
Create your own Examples with Conversational Programming

With Conversational Programming, it's easy to create your own examples...
Conversational Programming is a way to create simple G-code programs with CADCAM software. You simply answer questions in a simple Wizard format and it will generate the G-code for the operation.
More G-code Resources
- Beginner's Step-By-Step Guide to Making CNC Parts
- Wikipedia G-code Definition
- Our Free CNC Software List
Do You Have Some Cool G-code?
We're always on the lookout for cool G-code files to add to this page. If you have something you think is worthy, we're interested.
Here's the sort of thing we're looking for:
- Quick fun projects someone could CNC in a weekend.
- Useful G-code utilities such as subprograms that perform certain tasks that others may want to include in their own G-code.
- G-code that demonstrates some clever technique or a better experience others can learn from.
- 3D Printer G-code from slicing software. I don't yet have anything for a 3D Printer.
If you think you've got just the ticket, get in touch. Include your G-code, tell me what sort of control it runs on, what it is, and briefly say why you think it should be added to our G-code page. I'll let you know quickly whether I'm going to add it.
Cheers!

Where Can I Get Free G-code Files for 3d Printer?
The easiest way to get G-code files for 3D Printers is to use Slicer software on an STL file.
FAQs
What is a G-code file?
G-code files are the instructions your CNC Machine or 3D printer follows to create a part.
Where do I get G-code files?
G-code files typically come from one of these sources:
- CAM Software can produce G-code from a CAD model.
- Conversational CNC can produce G-code when you answer a few simple questions in a Wizard-like format.
- You can write G-code by hand, perhaps using a G-code Editor and Simulator to help.
- You can download G-code files from sources like this article.
Is STL a G-code file?
No, STL is a CAD file format. It defines the geometry of the part you want to create.
What software or app opens G-code files?
G-code files are most commonly opened by Machine Controller Software, such as GRBL, or by NC Viewer Software such as CutViewer.
How to convert a 3D Model to G-code?
For 3D Printers, you typically use Slicer Software to convert a 3D Model to G-code.
For other CNC Machines, you typically use CAM Software to convert a 3D Model to G-code.
Be the first to know about updates at CNC Cookbook
Join our newsletter to get updates on what's next at CNC Cookbook.