A more efficient G-Code viewer for large files

I've been experimenting with a new G-Code viewer, with the goal of removing the rather low limit on the size of files the current viewer can handle. It seemed like an interesting and fun challenge to handle very large and complex G-Code files in the browser efficiently.

It's still a very rough prototype, but in general it can display very large G-Code files in the browser with pretty low memory usage. I haven't managed to slice a file I couldn't display so far, the largest one I successfully loaded in the browser was around 1 GB. Memory usage is typically around 40-60% of the G-Code file size.

You can try the G-Code viewer at the following address:


or view the source at

It's open sourced under the Apache 2.0 license.

There is no progress bar or any feedback yet while loading, but it's quite fast and unless you load a very large file it should be finished in a few seconds. I got a bit sidetracked trying to make the parser fast, so while the viewer is seriously lacking in features, it makes up for that by being very fast in loading G-Code.

Right now this is a standalone project, but if I can get this working well enough it I'll take a look at whether it makes sense to create a library that can be integrated into Octoprint.

There are a lot of limitations right now, it only handles a subset of G-Code commands, but enough to display the stuff I've tried. I've tested it mostly with files slices by Slic3r PE so far. On Firefox you have to reload the page to load a new file if you have one loaded already, I didn't get the drag events right yet there. And you can only change the linewidth right now, I want to add more display parameters to this. Drawing is much faster on Firefox for some reason on my computer, I'm not yet sure if this is a general issue or not.


Really nice, and works very smooth. Nice and simple interface. Once you do get to a point, you should definitely look at integrating it within the OctoPrint gcode viewer viewModel. Any plans on supporting 3D view?

I've thought about a 3D view, and I actually have some experience in using WebGL for 2D stuff. But that area is rather complex and difficult to work with, you're close to the hardware and you never get any meaningful errors, at best you get just a black screen if you make a mistake. I'll probably try that at some point, but I'm not sure I'll succeed.

Cool, just a thought. I created a plugin that enables the 3d view in octoprint using its gcode.ws implementation. It's not great but does allow you to look at the object from upgraded gcode files.

Cool :slight_smile:
Can I switch between 3D and standard view when I use your plugin?

Yeah, it adds a 3D button to the gcode viewer tab that you toggle on/off. It's not very pretty, and it doesn't go along with print progress, etc. but does show the gcode as a 3d object.

1 Like

what a shame I hoped for a 3D progress :smiley:
But still thanks for the plugin - I'll test it soon :slight_smile:

1 Like