Nozzle Notes
Slicers & software

STL vs 3MF vs G-code: 3D Printing File Types Explained

STL and 3MF describe a model; G-code tells the printer what to do. Learn what each file contains and which one to use at each step of a print.

By Sepehr Sabbagh-pour · Published · Updated · 7 min read

Illustration: three graphite blocks in a row for three file stages: a wireframe mesh cube, a solid cube and a sliced cube
AI-generated illustration

STL and 3MF are model files, while G-code is the set of instructions a printer follows. STL vs 3MF comes down to context: STL stores only a triangle surface, 3MF can also carry multiple materials and project data, and G-code is what your slicer exports for one specific printer.

Mixing them up is why people download a model and cannot print it, or send a file the printer refuses. This explainer is based on Wikipedia, Prusa's documentation and the Marlin G-code index. For a closer look at the instruction file, read what G-code is and how to read it.

What is the difference between STL, 3MF and G-code?

STL and 3MF describe a model, and G-code is the instruction file your slicer produces from it.

  • STL: the oldest and most common model file. Shape only. No units, no color, no settings.
  • 3MF: a newer model format that can also carry print settings, multiple materials and more. Slicers use it to save projects.
  • G-code: the output of the slicer. Your printer reads it line by line. You cannot slice it again.

The usual flow is: design or download an STL or 3MF, open it in a slicer, then export G-code. If you have not picked a slicer yet, read what a slicer is.

STL: the shape and nothing else

STL was created for the stereolithography software of 3D Systems; Wikipedia dates the format to 1987. An STL file describes a raw surface made of triangles, each defined by its corner points and a direction it faces. Two details matter in daily use:

  • No scale information. Wikipedia notes that STL files contain no scale information and the units are arbitrary. Slicers usually assume millimeters. If a model imports tiny or huge, the units are the first thing to check.
  • No color or texture. STL describes only surface geometry, so it cannot hold color, materials or print settings.

STL files come in ASCII and binary versions; binary is more common because it is more compact. Almost every slicer and model site supports STL, which is why it remains the default for sharing a single part.

3MF: a model plus context

3MF (3D Manufacturing Format) is an open standard published by the 3MF Consortium. Wikipedia describes it as XML-based and designed for additive manufacturing, and says it differs from STL because manufacturing features such as hotend and bed temperatures, feed rate, part regions with multiple materials and support structures can be embedded in the file. The consortium has included CAD and manufacturing companies since 2015, including Autodesk, Dassault Systemes, HP and Microsoft.

In practice, this means a 3MF can hold more than one object, the position of each on the bed and, depending on the slicer, your chosen settings. Slicers use it as a project file. Prusa's Configuration Wizard even has an option to associate 3MF and STL files with PrusaSlicer, and notes that 3MF project files by default do not store the full path to the source models, because that could be a security risk when sharing a file.

Caution. What gets stored in a 3MF depends on the program that wrote it. A 3MF saved by one slicer may open in another with the geometry intact but the settings ignored. Check your slicer's documentation before relying on it to move settings between programs.

G-code: the printer's instructions

G-code is a programming language used to control CNC machines and 3D printers; Wikipedia says it is standardized in ISO 6983-1 and that it has many variants. Each line tells the machine where to move, how fast and what to do next. The Marlin firmware documentation indexes the commands: for example G0 and G1 are linear moves, G28 is auto home, G29 is bed leveling and G90 sets absolute positioning.

A slicer writes thousands of these lines, one set per layer. An illustrative line looks like G1 X50 Y50 F3000: move in a straight line to X 50, Y 50 at a feed rate of 3000. Your slicer sets every number.

Because the file is tied to the settings you chose, G-code is specific to one printer, nozzle, filament and profile. Treat it as a finished product: if you need a change, adjust the settings in the slicer and export again, rather than editing the file by hand.

Binary G-code (bgcode)

Some newer Prusa printers use a binary version. Prusa's open-source libbgcode project describes it as a block-structured format with separate blocks for metadata and G-code, compression for smaller files and a checksum for data validity. PrusaSlicer's first-print guide refers to exporting either G-code or bgcode. Check which one your printer accepts before choosing the export option.

What is inside an STL file, and why does that cause problems?

Wikipedia describes the binary layout precisely: an 80-byte header that software ignores, a 4-byte count of triangles, then 50 bytes per triangle (a normal vector, three vertices, and a 2-byte attribute field that should normally be zero). The ASCII version starts with the word solid and lists each facet as text, which is why ASCII files are far larger for the same model.

Because the file is only a bag of triangles, Wikipedia lists several limits that show up as slicing trouble:

  • Curves are approximated. Triangles can only approximate a curved surface, so users often export very large files to reduce the error. A coarse export prints visible facets.
  • A valid solid must be closed. Every edge should be shared by exactly two faces. Holes, reversed normals or non-manifold geometry can cause slicing failures or print errors, and automatic repair that merges nearby vertices can give unpredictable results.
  • Color is non-standard. Some programs hide color in the attribute bytes or header, but different programs use different conventions, so other software cannot reliably read it.
  • Units are not stored. Software usually asks the user, most often millimeters or inches.

If a slicer reports a non-manifold mesh or open edges, the fix is on the model side: repair it in the CAD or mesh program, or use the slicer's repair tool, then export again. What a slicer does explains why a broken mesh stops the slice.

What does 3MF add, and who maintains it?

Wikipedia says 3MF is built on ZIP and XML and the Open Packaging Conventions, so a .3mf file is a package rather than a flat list of triangles. The format was released on 29 April 2015 by the 3MF Consortium. Its founding members include Autodesk, Dassault Systemes, HP and Microsoft, and later members include Materialise, 3D Systems, Siemens and Stratasys. The same page says it became part of a Linux Foundation open standards project in 2022 and an ISO/IEC standard, 25422:2025, in 2025.

The practical gain over STL is that manufacturing information can travel with the model instead of being shared separately: Wikipedia names hotend and bed temperatures, feed rate, multi-material part regions and support structures. Which of these a given slicer actually writes or reads is up to that slicer, so test with your own program before relying on it.

Which format should you export from CAD or download for a given job?

SituationChooseReason
Uploading a single part to a model siteSTLEvery slicer opens it
Round or organic shape you will print largeSTL at a fine export tolerance, or 3MFA coarse triangle export shows facets
Multi-color or multi-material model3MFSTL has no standard place for material regions
Handing a project to someone using the same slicer3MF projectKeeps the plate layout and, in that slicer, its settings
Printing a jobG-code or bgcodeThe printer cannot read model files

Comparison table

STL3MFG-code
ContainsTriangle surface onlyModel data plus optional manufacturing featuresMachine instructions
Color and materialsNoYes, per the 3MF standardOnly as commands
UnitsArbitrary, not storedCheck the size after importSet by commands (for example G21 for millimeters)
Opened bySlicers, CAD, viewersSlicers and CADPrinters, G-code viewers
Editable in a slicerYes, as a modelYes, as a model or projectNo

G21 appears in the Marlin G-code index as the millimeter-units command.

Which file should you use?

Use STL to share a single part, 3MF to save slicer projects or multi-material work, and G-code (or bgcode) to send a job to the printer.

  1. Sharing or downloading a single part: STL is the safest choice for compatibility.
  2. Saving your work in a slicer: use the slicer's project format, often 3MF, so you do not lose object placement.
  3. Multi-color or multi-material models: choose 3MF, since STL cannot hold the information.
  4. Sending to the printer: export G-code (or bgcode, if your printer needs it) from the slicer.

Common mistakes

  • Trying to open G-code in a slicer to edit the model. It holds toolpaths, not a model. Go back to the STL or 3MF.
  • Printing at the wrong size. Unit confusion in STL files is common. Check the dimensions after import.
  • Reusing G-code on a different printer. It was sliced for one machine. Re-slice with the right profile.
  • Expecting settings to travel inside every 3MF. It depends on the program.

If your model comes from your own design, see designing your first print in Tinkercad for how to export. Once a print starts, how to 3D print covers the rest of the process.

This page is research from the sources listed, not from print tests.

Cura opens STL and 3MF files and outputs G-code; see Cura for beginners for how.

Related: How to send a print to your printer.

Creating your own file? See how to make a 3D print model and which format to export.

Frequently asked questions

What is the difference between STL, 3MF and G-code?

STL and 3MF describe a model, while G-code is the set of instructions your printer follows. STL holds only a triangle surface, with no units, color or print settings. 3MF is an open standard that can also carry manufacturing features such as multiple materials, which is why slicers use it as a project file. G-code is the slicer's output for one specific printer and profile, so you cannot slice it again. The usual flow is STL or 3MF in, G-code out.

Is 3MF better than STL?

For multi-material work and saving projects, yes, because 3MF can carry more information than STL, including multiple objects, their positions on the bed and, depending on the slicer, your settings. What a 3MF stores depends on the program that wrote it, so settings may be ignored when it opens in another slicer. STL is simpler and supported almost everywhere, so it remains the safest format for sharing a single part.

Can I convert G-code back to STL?

Not in a useful way. G-code holds toolpaths for one printer, nozzle, filament and profile, not the model itself, so it is a finished product rather than an editable design. If you need a change, keep the original STL or 3MF, adjust the settings in your slicer and export the G-code again. Trying to edit the printer file by hand is a common mistake and rarely worth it.

Why does my STL import at the wrong size?

STL files contain no scale information and the units are arbitrary, as Wikipedia notes. Slicers usually assume millimeters, so a model designed in inches or meters can import tiny or huge. Check the model dimensions right after import and scale it if they look wrong. Unit confusion in STL files is one of the most common causes of printing at the wrong size, so it is the first thing to check.

What file does my 3D printer need?

Most printers read G-code, which your slicer exports after you slice an STL or 3MF. Some newer Prusa printers use binary G-code (bgcode), a block-structured format with compression and a checksum, and PrusaSlicer's first-print guide refers to exporting either one. Some printers also read a sliced 3MF from their own slicer. Check your printer maker's documentation before choosing the export option.

Which file should you use for 3D printing?

Use STL when sharing or downloading a single part, because it is the safest choice for compatibility. Use your slicer's project format, often 3MF, to save your work so object placement is kept, and choose 3MF for multi-color or multi-material models since STL cannot hold that information. When you are ready to print, export G-code, or bgcode if your printer needs it, from the slicer.

Sources

Sepehr Sabbagh-pour

Founder and editor

Sepehr Sabbagh-pour

Software engineer since 2009 and Head of Engineering by day, a maker who has owned several 3D printers, writing practical guides to 3D printers, filament and running costs, with every article saying what was and was not tested.

Drafted with AI assistance, then edited and reviewed by Sepehr before it goes live. How we use AI.