Guide
Reading a G-code file: layers, print time, filament use and what the estimate leaves out
A slicer turns a 3D model into G-code, the list of moves a printer follows. The file is plain text and tens of thousands of lines long, so nobody reads it directly, but there are good reasons to look inside before printing: to see whether the first layer is where you expect, how much filament it will use, and how long it should take. This viewer opens a G-code file in your browser and draws it layer by layer.
How G-code describes a print
Each line is a command followed by letters and numbers. G1 X10 Y20 E0.5 F1800 moves the head to X = 10 and Y = 20 while pushing 0.5 mm of filament, at a feed rate of 1,800 mm/min, which is 30 mm/s. G0 is a rapid move, G2 and G3 are clockwise and counter-clockwise arcs, G90 and G91 choose absolute or relative positioning, M82 and M83 do the same for the extruder, and G92 E0 sets the extruder position back to zero. Text after a semicolon is a comment, and slicers use it for the layer number and often the estimated time.
Finding the layers
The viewer follows the head through every move, keeping track of the mode and resets. A move counts as printing when the extruder advances while the head moves in X or Y. A new layer begins when the head is already at a higher Z and starts extruding, so travel moves with a Z lift do not make false layers. The layer height is the average gap between layers after the first, because the first layer is often thicker.
The layer preview
The slider moves through the layers. The selected layer is drawn in blue, with the three below it faded if you tick that box, and travel moves can be shown as dashed orange lines. For each layer the page lists the length of extrusion, the time and the number of moves. Arcs are broken into segments of about half a millimetre.
Time and filament
For every move the length divided by the feed rate gives its time. With acceleration set above zero, each move is treated as a trapezoid that speeds up, cruises and slows down, which makes short moves slower. Filament is the sum of the positive E values, converted to weight with the density of the material and the filament diameter you choose. If the slicer wrote its own time estimate in a comment, the page shows it next to the computed one.
A worked example
The sample is a hollow square tower, 20 mm wide, printed in six layers of 0.2 mm with an outer loop and an inner loop on each layer. The part is 20 × 20 × 1.2 mm. Each layer extrudes 80 mm on the outside and 48 mm on the inside, 128 mm in all, so the six layers extrude 768 mm of path. With a 0.4 mm line and a 0.2 mm layer that needs about 25.5 mm of 1.75 mm filament, which is roughly 0.076 g of PLA, and the whole file takes about 27 seconds at the speeds written in it. Each layer has one retraction, so there are six.
Limits
The viewer is a quick inspector, not a simulator. It shows a top view of one layer at a time and no 3D preview, it does not model temperature, fans or firmware features such as pressure advance, and it ignores macros that expand inside the printer. Files for CNC mills and lasers have no extruder values and give an error. Very large files of more than 120 MB are refused.
Related tools
- STL Viewer shows the model that the G-code was made from.
- 3D Print Cost Calculator turns the filament and time into a price.
- Steps per mm Calculator fixes dimension errors that the preview cannot show.
- LiPo Battery Calculator is useful when you power a printer from batteries.
Checked against the current version of the G-Code Viewer on .

