G-Code Filament Analyzer – Filament, Layers and Time from Your G-Code File

Use the free G-Code Filament Analyzer below. It runs entirely in your browser, with no sign-up and no download.


What is actually in your G-code?

A sliced G-code file is a long list of instructions, and its size tells you almost nothing. A small file can print a dense part, and a large file can print a hollow one. The numbers that matter are hidden inside: how much filament the extruder will push, how many layers the print will build, and how long the printer will take. Slicers report these figures, but if you receive a file from someone else, or you want to check a slicer’s claim, you need to read the file yourself.

This analyzer reads your G-code file entirely in your browser. Nothing is uploaded anywhere, which matters because G-code files can be large and because your designs are your own. Drop in a .gcode file and it totals the extrusion, counts the layers, counts the lines and estimates the print time from the feed rates written in the file.

How the parser works

G-code moves are mostly G0 and G1 commands with X, Y, Z, E and F values. The E value is the extruder position, and filament used is the sum of its increases. The parser handles both absolute mode, where E counts up from zero and must be reset by G92 commands, and relative mode, set by M83, where each E value is itself the amount extruded by that move. Retractions, which are negative E moves in relative mode or decreases in absolute mode, are not counted as filament used, because retracted filament is pushed back out again by the next move.

Layers are counted from layer markers when the slicer writes them, as comments like ;LAYER:12, and otherwise from distinct Z heights at which extrusion happens. The line count is simply the number of lines in the file, which is a useful rough measure of how detailed the toolpath is. Print time is estimated by dividing each move’s distance by its feed rate and adding the results. That is an estimate, clearly labelled as one, because real printers accelerate and decelerate, and those ramps add time that the raw feed rates do not show.

A worked example

Try the sample G-code built into the tool. It homes, moves to a first layer height of 0.2 millimetres, and extrudes 5 millimetres at a time across four moves, rising to a second layer halfway through. The analyzer reports 20 millimetres of filament, 2 layers and 8 lines. With the default 1.75 millimetre filament and PLA density of 1.24 grams per cubic centimetre, that 20 millimetres weighs about 0.06 grams, a tiny figure that confirms the sample is a toy path, not a real part, and that the maths scales correctly.

Now load a real file and compare the analyzer’s totals with your slicer’s. They should agree closely on filament and layers. If filament disagrees by a large margin, check whether the file uses relative extrusion, which some slicers and firmware setups prefer, or whether it contains multiple tools, in which case each tool’s extrusion is tracked separately by the firmware and a simple total needs care.

Why the time estimate runs short

Almost every G-code time estimate runs shorter than the real print, and the reason is acceleration. A move commanded at 100 millimetres per second does not travel at that speed for its whole length. It speeds up from rest, may never reach full speed on a short segment, and slows down at the end. Jerk and junction deviation settings shape those ramps further. On prints with many short segments, such as detailed curves, acceleration time dominates, and the estimate can be short by 20 percent or more.

Use the estimate for comparing files and for rough planning, not for promising a finish time. If a deadline matters, print a small test, measure the real time against the estimate for that file, and apply the same correction factor to similar files. That single calibration step is worth more than any more elaborate formula.

Frequently asked questions

Does the analyzer work for resin printers? No. Resin printers use different file formats and do not extrude filament, so G-code analysis does not apply to them.

Why does my file show zero layers? Usually because the file uses a dialect the parser does not recognise, or because extrusion happens without Z moves in the file. Check that the file is plain G-code and that it contains G1 moves with E values.

Is my file uploaded to a server? No. The FileReader API reads the file on your own device, and the analysis runs in your browser tab. Closing the tab discards the file.

Spanish version

Analizador de Filamento G-Code – Filamento, Capas y Tiempo desde tu Archivo G-Code

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top