FDM · laser · CNC · layer by layer · time and filament

G-code Viewer and Analyzer

Open a G-code file, step through its layers in 2D and 3D, and read a modelled print time, filament use, retractions and temperatures.

G-code file

.gcode, .nc, .gco, .txt

Drop a G-code file here or click to choose

Plain text up to 400 MB, read as a stream. Binary .bgcode is not supported.

Machine model

Used for the time estimate

Picked from the start of the file; change it if it guessed wrong.

M204 lines in the file override the accelerations.

Open a G-code file to see its toolpath and totals.

G-code Viewer and Analyzer

Operator: Abdulla Al Fahad. How tools are built and checked

A G-code file is a list of instructions, and the cheapest time to find out that it prints a 40 mm part at the wrong scale, retracts 300 times in one layer or heats the nozzle to 280 °C is before the machine starts. Looking at the toolpath and the totals answers those questions in seconds.

Files up to 400 MB are read as a stream in a background worker, so a 200 MB print does not freeze the page and can be cancelled.

The page works for 3D-printer, laser and CNC files, and the file type decides what counts as a "layer": an extrusion layer, a laser pass, or a depth pass at one Z level.

Key features

  • Layer slider with a top view of the selected layer and a 3D view of every layer up to it, extrusion in orange, the current layer in yellow and travel moves optional
  • Modelled print time from a trapezoid planner with acceleration, travel acceleration and junction speed you can change, and M204 lines in the file respected
  • Filament length (net of retractions), weight from a diameter and material density, retraction count and mean length, layer heights and temperature commands
  • Laser mode that counts a move as burning only while M3 or M4 is on with S above zero, and CNC mode that treats G1 to G3 as cutting and G0 as rapid
  • Slicer comments (Cura TIME and Filament used, PrusaSlicer estimated printing time and filament used) shown next to the page's own estimate, and a per-layer CSV

How the file is read and timed

The reader tracks what a controller would: G90 and G91, M82 and M83 for extrusion, G20 and G21, G92 position resets, and G28 (assumed to home to zero, which the notes say). Extrusion follows Marlin 2: G91 makes E relative along with X, Y and Z, M82 and M83 set it explicitly, and G90 returns E to absolute. That matters for Cura's stock Creality end script, which runs G91, G1 E-2, G1 E-2 Z0.2 and G90 under absolute extrusion: the two retractions are relative, so they take 4 mm off the filament total instead of being read as absolute positions. A line may carry several G and M words, such as G90 G1 X10. Words can be written with or without spaces, N line numbers, checksums and both comment styles are stripped, and arcs from G2 and G3 (I and J, or R) are cut into segments of about 10 degrees or one millimetre, whichever is shorter, capped at 360 per arc.

In a printer file a move is extrusion when E increases and the nozzle travels. A negative E with no travel is a retraction and G10 is counted as one; the filament figure is the sum of all E changes, so a retract followed by its prime cancels. A new layer starts on the first extruding move that rises more than 0.004 mm above the current layer, so z-hops in travel moves do not create layers and a spiral vase print reports one layer per 0.004 mm of rise, capped at 20,000 layers.

The planner gives each move a trapezoid: it accelerates from the entry speed to the programmed feed, cruises and slows to the exit speed, all at the acceleration in force. Entry and exit speeds at a corner come from the classic jerk rule: the speed is scaled down when the vector difference between the old and new velocity exceeds the junction speed. There is no look-ahead buffer across many short moves, no heat-up wait (M109 and M190 add nothing) and no per-axis limits, so the number is an estimate and not the machine's clock.

Drawing budgets protect the browser: up to 3 million extrusion segments and 1.5 million travel segments are kept for display; if a file has more, drawing stops and the page says where, while the totals keep counting. Reading stops at 25 million lines, and a move to a coordinate beyond 1,000 km is skipped and counted as not interpreted.

How it works

A worker streams the file in chunks, splits lines, parses each into words and updates the machine state. Segments go into typed arrays in file order, so the layers are ranges of one array and the slider only changes how much of it is drawn.

Moving the slider changes the drawn range and swaps one small buffer for the current layer, so nothing large is uploaded to the graphics card again.

Changing the file type or any planner number restarts the analysis from the first line, because it changes how every move is classified or timed.

When this helps

  • A 6-hour print is queued overnight. The summary shows the hotend reaching 285 °C for a file meant for PLA at 210 °C; the temperature list names the line, and the wrong profile is caught before the print starts.
  • A laser job from a design program burns two 50 mm sides at S800 and returns along a 70.7 mm diagonal with M5 sent first. Laser mode reports 100 mm of burn path and 70.7 mm of laser-off travel, which confirms the diagonal is only a positioning move.
  • A CNC pocket file cuts at Z -1 and Z -2. CNC mode lists two depth passes, a Z range of -2 to 5 mm, and 47 mm of cutting path: two 20 mm passes plus the 6 mm and 1 mm plunges.

Opening a file

  1. Drop the G-code file. The type (printer, laser or CNC) is guessed from the first 256 KB; change it if the guess is wrong.
  2. Read the summary: modelled time, path lengths, filament and temperatures, and the slicer's own numbers if the file has them.
  3. Move the layer slider and check the top view for gaps, stringing travel or a part off the bed.
  4. Set acceleration to your printer's configured value and the filament diameter and material to get grams.

Example

A hand-written two-layer test: a 20 mm square printed at 30 mm/s, 1 mm of E per side, Z 0.2 and 0.4, one 0.8 mm retract and prime between layers

G1 Z0.2 F1200 / G1 X10 Y10 F6000 / G1 X30 Y10 E1 F1800 / G1 X30 Y30 E2 / G1 X10 Y30 E3 / G1 X10 Y10 E4 / G1 E3.2 F2400 / G1 Z0.4 F1200 / G1 E4 / (the same square again, E5 to E8)

Totals at 1,000 mm/s² printing and 1,500 mm/s² travel

2 layers at Z 0.2 and 0.4; extrusion path 160 mm; travel 14.5 mm
Filament net 8 mm, which is 0.0239 g of PLA at 1.75 mm and 1.24 g/cm³; 1 retraction of 0.8 mm
Modelled time 7.04 s, of which 0.24 s is travel moves (6.95 s with printing acceleration raised to 3,000 mm/s²; 6.96 s with a 20 mm/s junction speed)

Limits

Klipper macros, firmware-specific commands and G5 Bezier curves are counted under Not interpreted and skipped, so a file that depends on them is incompletely drawn.

Arcs in the G18 or G19 plane are drawn as straight lines.

Binary G-code (.bgcode) is refused. Export plain text from the slicer.

A heater target that no printer can reach, such as M104 S99999 or a bed above 200 °C, is shown in the notes with its line number as a probable typo; the maximum temperatures in the summary still show the value written.

Volumetric extrusion (M200), firmware retraction settings and flow multipliers (M221) are not interpreted, so a print sliced with a 90 percent flow multiplier uses less filament than the page reports.

  • Compare the page's time with the slicer's line when both appear: a gap above 30 percent usually means the slicer used a different acceleration, so enter that value and check again.
  • Turn on travel moves for one layer to see whether a long diagonal travel crosses the part, which is where stringing shows up.

Common errors and how to fix them

"No extruding moves were found"
The file is probably for a laser or a router. Change the file type; with the wrong type no layer can be drawn.
"Drawing stopped at 3,000,000 extrusion segments"
The totals are still complete. Reduce the arc resolution or the segment count in the slicer if you need to see every layer.

Best practices

  • Set the acceleration to what the printer actually uses (the M204 lines, or the value in its configuration) before trusting the time, and treat the result as a ranking between two files, not a promise.
  • Check the first-layer height and the temperature lines on every new profile before printing.

What changes in laser and CNC mode

In laser mode a move counts as burning only while M3 or M4 is on, S is above zero, and the move is G1, G2 or G3; G0 never burns. G0 moves use the rapid feed you enter, other laser-off moves keep the feed in force, and the summary shows the highest S instead of filament and retraction figures.

In CNC mode G1, G2 and G3 are cutting moves and G0 is a rapid at the rapid feed. Motion is modal, as in grbl, LinuxCNC and Mach3: a line that holds only coordinates, such as X40 Y40 after a G1, repeats the last motion mode, so a 40 mm square written as one G1 line and three bare coordinate lines reports 160 mm of cutting. Laser files get the same treatment, and a bare S line changes the power. In printer mode a coordinate-only line is not interpreted, because Marlin and Klipper do not repeat the previous move. A new pass begins at the first cutting move that stays at a new Z level after a plunge, so the pass list shows each depth, and the time model uses the same acceleration and junction speed as the printer mode.

Frequently asked questions

Why does the modelled time not match my slicer?

Slicers run a look-ahead planner that also respects each axis's own limits and the firmware's corner rules, and some add heat-up or tool-change time. This page times each move on its own with one acceleration, so on files with many short moves it usually comes out longer.

Why does the time show hundredths of a second?

Under a minute the fraction decides whether two numbers agree: a 100 mm move at 6,000 mm/min with 1,500 mm/s² takes 1.07 s, and the summary also says how much of the total went to travel moves. From a minute upwards the time is shown in whole seconds.

How does it treat a spiral vase print?

Z rises continuously, so a new layer starts every 0.004 mm of rise. A 100 mm tall vase would need 25,000 of those, so after 20,000 layers the rest is folded into the last one. Totals stay correct; only the slider resolution is lost.