Quick answer
To see what a .gcode, .nc or .tap file will do, open it in a G-code viewer such as ViewGcode, which draws the toolpath in 2D or 3D in your browser without uploading the file. To read or edit the commands, open it in any text editor.
Ways to open a G-code file
- An online G-code viewer. Drop the file onto the page and it draws the path, with layers for 3D prints and rapid, feed and arc moves for CNC. With ViewGcode the file is read in your browser and never uploaded.
- A text editor. Notepad, TextEdit (in plain-text mode), VS Code and similar editors show the commands line by line. This is the right tool for reading or changing values, but it shows no shape, and very large files can be slow to open.
- Your slicer. Several slicers can preview a G-code file they produced; look in the File menu of your slicer (menu names vary by version).
- CAM or controller software. CNC controllers and CAM programs usually include a backplot or simulation view for the programs they run.
Do not send a G-code file you have not looked at straight to a machine, especially one downloaded from somewhere else. A quick look in a viewer catches many obvious problems, although it cannot guarantee a job is safe.
Looking for a viewer for a specific job? See the 3D printer G-code viewer or the CNC G-code viewer.
What G-code looks like
Open any G-code file in a text editor and you will see short commands, one per line. A few typical lines:
| Line | What it tells the machine |
|---|---|
G21 | Use millimeters (G20 is inches). |
G90 | Positions are absolute coordinates (G91 is incremental). |
G0 X0 Y0 Z5 | Rapid move to X0, Y0, Z5, not meant to cut or print. |
G1 X10 Y0 F300 | Straight move to X10 at a feed rate of 300. |
G2 X20 Y10 I10 J0 | Clockwise arc to X20, Y10 around a center offset from the start point. |
M3 S12000 | Start the spindle (CNC), a command that moves nothing by itself. |
; comment | Text after a semicolon is a note for people. Slicers use these for layer markers. |
A viewer reads the movement lines (G0, G1, G2, G3) and draws them as a path, which is much easier to check than reading thousands of lines of numbers.
What the file extension means
The extension is a hint about where a file came from, not a different format. All of these are normally plain text.
| Extension | Where you usually meet it |
|---|---|
.gcode | The standard extension from 3D-printing slicers; also used for other machines. |
.gco | A shortened form of .gcode, seen with some slicers and printer firmware. |
.gc | A less common short form; treat it like .gcode. |
.g | Used by some RepRap-style firmware, for example Duet. On those systems .g files can also be macros or configuration files, which are not toolpaths. |
.nc | “Numerical control”; common for CNC mills and routers and for output from many CAM programs. It is also used for NetCDF scientific data, which is not G-code. See the NC file viewer. |
.tap | An older CNC-style extension, often seen with PC-based CNC controllers. |
.cnc | Used by some CAM and controller software. |
.ngc | Typically LinuxCNC programs. |
.txt | G-code saved with a generic extension. |
The contents matter more than the name. ViewGcode accepts any of the extensions above and also checks that the file contains recognizable motion commands (G0, G1, G2, G3).
Files that are not plain text
Two formats look like G-code files but are not text. A .bgcode file is PrusaSlicer’s binary G-code format, and a .gcode.3mf file is a packaged project from Bambu Studio. A text editor shows unreadable characters, and ViewGcode reports that the file looks like a binary file rather than text. In your slicer, export a standard .gcode file instead; printer settings in some slicers include an option for binary G-code, and menu labels differ by version, so check yours. More fixes are in the troubleshooting guide.
If the file opens but looks wrong
Check the units (inch or millimeter), the profile (3D printing or CNC) and the parser notes for skipped commands. The troubleshooting guide goes through each case.