An STL file, or “stereolithography” file, is a very common 3D file type. It defines a 3D object using a number of triangular shapes, collectively known as tessellation. This file type is downloadable from 3D printing repository websites such as Thingiverse, MyMiniFactory, and Repables.
On the other hand, G-code files are the commands that tell a 3D printer how to print a 3D object. G-code typically describes printer parameters, such as speed and temperature, as well as the geometry of the 3D object. Typically, STL files are converted to G-code files using a slicer like Cura. However, reversing that process, going from G-code to STL, is much less common.
Why might someone want to convert from G-code to STL?
The main reason to do this is if you have a G-code file without the original 3D STL file. This is a somewhat error prone and experimental process, and it is common to experience errors in conversion. Thus, tweaking conversion parameters is often needed to obtain ideal results.
For instance, G-code files often contain non-part-related information, such as supports. When using converters from G-code to STL, these features will remain in the resulting STL and will need to be manually removed in a 3D editing software to fully recover the original STL file.
Disregarding any STL “post-processing” that may need to be done, there are two straightforward methods that can be used to convert from a G-code file to an STL.