Skip to content
3DToolBench

Convert G-code to STL

G-code is a list of nozzle moves, not a model. This tool rebuilds the plastic those moves lay down — each line given the width and height it was printed at — and hands it back as an STL. Read the first section before you use the result: you get the shape of the print, not the model the print was sliced from.

Drag a 3D file here, or.

This page is set up for G-code files. Other formats we can read work here too.

The file is read on your own computer. It is never uploaded.

Add a file to switch this on.

Your file is read by your own browser and never sent to a server. There is no upload, no account and no copy of your model anywhere but on your computer.

What you get back, and what you do not

The original model is not inside a G-code file. A slicer cut it into layers, turned each layer into paths for the nozzle, and threw the model away. No converter anywhere can get it back, because it is not there to get.

What is there is every move that pushed out plastic, and how much plastic each move pushed. That is enough to rebuild the print itself. Each line becomes a strand with a width and a height, and the strands stacked up are the object that would come off the bed.

So the result is stepped, like the print. Every layer shows, and a curved top is a staircase of 0.2 mm steps. Anything the slicer changed on purpose — a hole made slightly bigger, a first layer pulled in so it does not spread — is in the result, because it was in the print.

Why the file is much bigger than the model was

A model describes a surface. A rebuilt print describes every line of plastic separately, and a print has tens of thousands of lines. Each one becomes a small closed tube that overlaps its neighbours, which is how plastic is really laid down. It is also why a 2 MB model, sliced and rebuilt, can come back as a 60 MB STL.

Two settings keep this under control. "The part only" leaves out infill, supports, the skirt and any prime tower, which usually cuts the file to a third and leaves the outside of the part exactly as it was. "Fast" gives every line a square cross-section and simplifies curves to within a third of a line width, which you cannot see at print scale.

If a print is too large to rebuild in a browser tab at the settings you chose, the tool steps down on its own — accurate to fast, then everything to the part only — and says which step it took.

When this is useful

You have a G-code file and nothing else: a print someone shared, a job from a print farm, a file from years ago whose model is lost. The rebuilt STL is something you can look at, measure, and put next to other parts in CAD to check a fit.

You want to show what a print will really look like, layers and all, rather than the smooth model it came from.

You want to print it again on a different printer. Slicing the rebuilt STL again is much safer than running G-code made for somebody else’s machine, which can drive the nozzle into the bed. Expect the old layer lines to show on the new print; for a functional part that is usually fine.

When it is not the right tool

If you still have the model, use the model. An STL sliced from a real model is smooth and small; one rebuilt from G-code will always be stepped and large.

If you only want to look at the print or check it before you start it, the G-code viewer is the better page. It draws the lines directly, layer by layer, and tells you the print time and the filament without building anything.

Binary G-code (.bgcode), which PrusaSlicer writes for its newer printers, cannot be read yet. PrusaSlicer writes plain G-code for the same printer if you untick one setting, and the message you get says which.

Units and position

G-code states its units: G21 means millimetres and G20 means inches, and inches are converted. The model comes out in the printer’s own coordinates, Z up, sitting exactly where it sat on the bed. Several parts from one plate therefore stay where they were relative to each other.

If you want the part at the origin instead, move it in your slicer or CAD program after converting. Nothing about its shape changes when you do.

What survives, and what does not

Kept in the STL file

  • The shape of the print, layer by layer, at its real size in millimetres
  • Where the part sat on the bed, so parts from one plate stay in place
  • Each extruder as its own object, for a print in more than one material

Lost on the way

  • The original model — G-code never held it, so the result is an approximation
  • Smooth curves: every layer shows as a step
  • Infill, supports and the skirt, unless you ask for everything that was printed
  • Colour and material, which G-code names only as a tool number

How to convert G-code to STL

  1. Drop the G-code file in

    A .gcode, .gco or .g file from any slicer works, and so does the sliced .gcode.3mf that Bambu Studio and OrcaSlicer export. The rebuilt print appears in the 3D view.

  2. Choose what to rebuild

    Leave it on the part only unless you really need the infill or the supports. It is a much smaller file, and the outside of the part is easier to see.

  3. Choose the line shape

    Fast is right for looking and measuring. Accurate rounds each line the way plastic really lies, for a render or a close-up, at about twice the triangles.

  4. Check the size

    The width, depth and height under the 3D view are the printed size. G-code states its units, so they should match what came off the printer.

  5. Convert and download

    Binary STL is the smaller STL. If the triangle count is very high, the 3MF converter makes a smaller file from the same print.

G-code and STL compared

G-code and STL compared, row by row
PropertyG-code.gcode .gco .gSTL.stl
File contentsPlain text, one machine command per line, often with a slicer’s settings in comments.Binary or plain text. Binary is an 80-byte header, a triangle count, then 50 bytes per triangle.
GeometryNone. It is a list of movements, already sliced into layers.Triangles only. Curves are approximated when the file is made, and cannot be recovered.
UnitsMillimetres, set by a G21 command at the top of the file.None. The file stores bare numbers, and every reader has to guess what they mean.
Colour and textureTool changes only, on printers that have more than one.None. There is no place in the format for a colour, a material or a texture.
Separate objectsLayers, in the order they will be printed.One body. Several parts written into one STL become one undivided lump of triangles.
Published byRS-274, from the 1950s. Every machine speaks its own dialect.3D Systems, 1987, for the first stereolithography machines.
Written byCura, PrusaSlicer, OrcaSlicer, Bambu Studio and every CAM program.Every CAD program and every slicer, as the common denominator.

Questions

Can I get the original STL back from a G-code file?
No, and no tool can. The slicer keeps the nozzle paths and throws the model away. What you get here is the print rebuilt from those paths: the right shape and size, with the layers showing.
Why is the STL so large?
Every line of plastic becomes its own small solid, and a print has tens of thousands of lines. Choose "The part only" to leave out infill and supports, and Fast for simpler lines.
Will the rebuilt STL print?
Yes. Every strand is closed, so a slicer sees solid plastic, and it merges the overlapping strands when it slices. The surface will show the old layer lines as well as the new ones.
Does it work with Bambu Studio files?
Yes. Drop the .gcode.3mf that Bambu Studio or OrcaSlicer exports for a sliced plate, and the G-code inside it is read. A project 3MF that has not been sliced holds the model itself, and the 3MF to STL converter is the page for that.
Why is the volume higher than the filament I used?
Neighbouring strands overlap, as they do in a real print, and each one is measured on its own. So the volume counts the overlaps. For the real amount of filament, open the file in the G-code viewer.
Is my file uploaded?
No. The G-code is read by your own browser and the model is built on your own computer. Nothing is sent anywhere.

Having it printed

If the part is larger than your bed, needs a material your printer cannot handle, or you do not have a printer, these will print it and post it to you. Work out what it would cost you first — the cost calculator on this site gives you a figure to compare against.

These are ordinary links, not paid referrals — we earn nothing if you use them. The converter above is the same whether you do or not.

Where to go next