File formats and open data
📍 Where we are: Part III · The Software Stack — Chapter 9 of 16. We have seen the tools that make models, slice them and send them to printers. Here we open the envelopes they pass around: the file formats, and the licences that decide who may reuse them.
A file format is a shipping box with a packing list. STL is a plain box of triangles with no packing list at all: it does not say whether the numbers are millimetres or inches, or what colour anything is. 3MF is a labelled box with the units, the build layout and optional extras written on it. STEP is the architect's exact drawing instead of a pile of flat tiles. G-code is not a model at all; it is the machine's to-do list. Choosing the right box decides how much information survives the trip.
What this chapter covers
We look at the formats a 3D-printing workflow actually touches, in the order a part meets them: STEP at design time, STL and 3MF at exchange, G-code at the machine. We also meet two ways of describing geometry that are not triangle meshes (volumes and implicit functions), the metadata that formats can and cannot carry, and the practical rules for sharing and reusing designs from online repositories. Two short scripts, both run, let you see the difference between formats in actual bytes.
STL and its limits
STL was introduced in the late 1980s for 3D Systems' stereolithography machines and became a de facto standard for rapid prototyping and 3D printing; it was first documented in a 1988 interface specification, and the Library of Congress format description notes that its compilers could not locate a copy of the original specification [1] [2]. It stores only surface geometry. Its binary form is an 80-byte header, a 4-byte little-endian triangle count, then 50 bytes per triangle: twelve 32-bit floats (a normal and three vertices) and a 2-byte attribute field that should normally be zero; the script below checks this layout against the file size. The ASCII form wraps the same data in solid, facet normal and vertex text lines. A classic analysis of STL files describes how defects in this triangle soup can be detected by building a polyhedral data structure from the file [3]; standard AM textbooks place the STL file as a step in the data-preparation chain between CAD and machine [4].
The limits follow from that design:
- No units. Nothing in the file says millimetres or inches, so software has to ask or guess; none of the fields above holds a unit.
- No colour or material. Non-standard binary variants hide colour in the header or attribute bytes, and they disagree with each other; the Library of Congress description records two incompatible colour conventions [1].
- No shared vertices. Each triangle lists its own three corners, so connectivity has to be rebuilt, and a mesh is only printable if it is closed with no self-intersections, which the format does not enforce; tessellation errors such as gaps and holes are common enough that files often need checking and repair before printing [2] [3]. The process-planning survey cited in Slicers catalogues the repair methods [5].
- Curves are approximated. Triangles cannot be a perfect cylinder; accuracy costs file size.
You can see the redundancy in real output. A mounting plate with four holes and rounded corners, exported from CadQuery (see Open CAD and code-driven design) as binary STL, contained 2,556 triangles, so 7,668 stored vertices, of which only 1,272 were distinct. I counted this with a script of my own, on one file; the ratio depends on the mesh.
3MF: a modern container
The 3D Manufacturing Format (3MF) is developed by the 3MF Consortium, a Joint Development Foundation project affiliated with the Linux Foundation; its specifications are freely available and royalty-free, and the page now lists the core specification as an international standard, ISO/IEC 25422:2025 [6]. The core specification text is published in a public GitHub repository under the BSD-2-Clause licence and defines units, vertices, triangles and metadata [7]. Published extensions listed on the 3MF site include Materials and Properties, Production, Slice, Beam Lattice, Boolean Operations, Displacement, Secure Content, Volumetric and Toolpath, the last two added recently (the page dates the Volumetric extension 2025-11-13) [6].
Inside, a 3MF file is a ZIP package. When I unpacked files written by CadQuery and by the lib3mf library, each contained [Content_Types].xml, _rels/.rels and 3D/3dmodel.model, an XML file whose root element carries a unit attribute (millimeter in both) and which lists vertices once and triangles by index.
Each format answers a different question: what shape, what machine moves, or what volume.
Original diagram by the authors, created with AI assistance.
A script to see the difference
This script uses only the Python standard library. It writes a 10 mm cube as a binary STL and as a hand-built 3MF package and prints how each stores the vertices.
import struct
import zipfile
s = 10.0
V = [(0, 0, 0), (s, 0, 0), (s, s, 0), (0, s, 0), (0, 0, s), (s, 0, s), (s, s, s), (0, s, s)]
F = [(0, 2, 1), (0, 3, 2), (4, 5, 6), (4, 6, 7), (0, 1, 5), (0, 5, 4),
(1, 2, 6), (1, 6, 5), (2, 3, 7), (2, 7, 6), (3, 0, 4), (3, 4, 7)]
def normal(a, b, c):
u = [b[i] - a[i] for i in range(3)]
v = [c[i] - a[i] for i in range(3)]
n = [u[1] * v[2] - u[2] * v[1], u[2] * v[0] - u[0] * v[2], u[0] * v[1] - u[1] * v[0]]
length = sum(x * x for x in n) ** 0.5
return [x / length for x in n]
# --- binary STL: 80-byte header, uint32 triangle count, 50 bytes per triangle ---
with open("cube.stl", "wb") as f:
f.write(b"cube".ljust(80, b" "))
f.write(struct.pack("<I", len(F)))
for a, b, c in F:
tri = (V[a], V[b], V[c])
f.write(struct.pack("<12fH", *normal(*tri), *tri[0], *tri[1], *tri[2], 0))
# --- 3MF: a ZIP package with a content-types list, a relationship, and one XML model ---
model = ('<?xml version="1.0" encoding="UTF-8"?>\n'
'<model unit="millimeter" xml:lang="en-US" xmlns="http://schemas.microsoft.com/3dmanufacturing/core/2015/02">\n'
' <metadata name="Title">cube</metadata>\n'
' <resources><object id="1" type="model"><mesh>\n <vertices>\n'
+ "".join(f' <vertex x="{x}" y="{y}" z="{z}"/>\n' for x, y, z in V)
+ ' </vertices>\n <triangles>\n'
+ "".join(f' <triangle v1="{a}" v2="{b}" v3="{c}"/>\n' for a, b, c in F)
+ ' </triangles>\n </mesh></object></resources>\n'
' <build><item objectid="1"/></build>\n</model>\n')
content_types = ('<?xml version="1.0" encoding="UTF-8"?>\n'
'<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">\n'
' <Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/>\n'
' <Default Extension="model" ContentType="application/vnd.ms-package.3dmanufacturing-3dmodel+xml"/>\n'
'</Types>\n')
rels = ('<?xml version="1.0" encoding="UTF-8"?>\n'
'<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">\n'
' <Relationship Target="/3D/3dmodel.model" Id="rel0" '
'Type="http://schemas.microsoft.com/3dmanufacturing/2013/01/3dmodel"/>\n</Relationships>\n')
with zipfile.ZipFile("cube_handmade.3mf", "w", zipfile.ZIP_DEFLATED) as z:
z.writestr("[Content_Types].xml", content_types)
z.writestr("_rels/.rels", rels)
z.writestr("3D/3dmodel.model", model)
print(f"STL: {len(F)} triangles x 3 = {3 * len(F)} stored vertices; no unit field")
print(f"3MF: {len(V)} vertices shared by {len(F)} triangles; unit=millimeter")
Run status: executed with Python 3.14 (standard library). Output: STL: 12 triangles x 3 = 36 stored vertices; no unit field and 3MF: 8 vertices shared by 12 triangles; unit=millimeter. The STL is 684 bytes, equal to 84 + 50 x 12. I then loaded cube_handmade.3mf with the lib3mf Python package (version 2.5.0, installed with pip install lib3mf in my test); it read 8 vertices and 12 triangles, reported the mesh manifold and oriented, and the unit as millimetre. That check is one reader's opinion; it is not a conformance certificate.
A caution about validation. The 3MF file that CadQuery 2.8.0 wrote for my mounting plate was rejected by lib3mf 2.5.0 with "Content Types does not contain extension for relatioship"; after I patched that in, it failed again with "No Model Object ID has been given". I did not establish which side is at fault, and a more lenient reader may open the file. The practical lesson is to test your export with the reader you care about, ideally a strict one, before you ship files to someone else's printer.
AMF
The Additive Manufacturing File Format is ISO/ASTM 52915. ISO lists the 2020 edition (AMF version 1.2) as current, last reviewed and confirmed in 2026. It specifies an XML-based interchange format, with a published XSD schema, intended to replace STL by supporting colour, texture, material and substructure [8]. Of the tools in this book, CadQuery lists AMF export [9] and so does OpenSCAD's manual [10]. I did not test AMF round trips, and I do not have data on how widely printers read it.
STEP: exact geometry for design
STEP (ISO 10303) is the CAD interchange family. Its Application Protocol 242, "Managed model-based 3D engineering", is the successor of AP203 and AP214 and also covers product manufacturing information such as tolerances [11]. A STEP file stores exact B-rep surfaces, not triangles. When I exported the plate from CadQuery, the file was plain text starting with ISO-10303-21;, and its FILE_SCHEMA line named the older automotive-design schema (214), which tells you the default Open CASCADE writer in that version, not what STEP can do. Because STEP keeps exact surfaces, it is the better file to send to another CAD user; a mesh is the better file to send to a slicer, and some slicers import STEP directly: PrusaSlicer 2.5.0's release notes list "STEP file import" [12]. An open STEP viewer, Foxtrot from Formlabs, exists but its authors call it a proof of concept that may fail to triangulate some surfaces [13].
G-code and its dialects
G-code is a text instruction language, and the "dialect" depends on the firmware. Marlin documents G1 as a linear move with X, Y, Z, E and F [14]. Klipper supports a standard subset (for example G0, G1, G28, M104, M109, M140, M190) but says it is not a goal to support every possible command; instead it adds human-readable extended commands such as SET_HEATER_TEMPERATURE HEATER=<heater_name> TARGET=<temperature> and SET_PRESSURE_ADVANCE ADVANCE=<value> [15]. Rarer commands can be built with a gcode_macro [15]. So G-code from a slicer is tuned to a firmware: the start and end macros, and any extended commands, must exist on the machine.
Plain text is easy to read but bulky. Prusa's libbgcode defines binary G-code (.bgcode): separate blocks for metadata and G-code, encoding and compression to reduce size, and a checksum, under AGPL-3.0 [16]. I did not verify which firmware versions read it.
Volumes and implicit models
Not every geometry is a surface. OpenVDB is an open-source C++ library from DreamWorks Animation, now maintained by the Academy Software Foundation, for sparse volumetric data on three-dimensional grids, released under the Apache License 2.0 (the README notes a completed move from the Mozilla Public License 2.0) [17]. Its core data structure was published in 2013 as a hierarchical sparse volume with dynamic topology [18]. The foundation's site is a further overview [19]. libfive defines solids as mathematical functions and meshes them into watertight, manifold triangle meshes [20]. The 3MF Consortium lists a Volumetric extension for voxel and implicit data, which signals that standards are starting to carry such models into the printing pipeline [6]. I have not tested any printer or slicer that consumes a volumetric 3MF; this is an emerging area, not a settled workflow.
Metadata and sharing
STL has nowhere to put an author, units or a licence. 3MF carries metadata entries in its XML, as the Title entry in the script above and the application and creation-date entries I saw in CadQuery's file. A practical habit is to ship a short README or licence file next to a model, regardless of the format.
For reuse, the Creative Commons licences are the common vocabulary. CC BY allows reuse including commercial reuse with credit; CC BY-SA adds that adaptations be shared under the same terms; the NC variants allow only non-commercial use; ND variants forbid adapted copies [21]. Researchers have used the licence field as data: the Thingi10K dataset (described in the dataset's own arXiv paper, which has no DOI and is kept as the primary source) collected 10,000 models from an online sharing site and analysed their geometry and contexts such as licences and tags, publishing the collection and statistics freely [22]. I could not open the official Printables or Thingiverse licence pages for this chapter (the requests were refused) and the third-party summaries I found were not authoritative, so I make no claim about which licences each site offers or defaults to; read the terms on the page of the model you want to use. The relationship between design licences and hardware licences is covered in Licenses and the economics of openness.
Open-standard efforts
Open formats here come from two directions: consortia (3MF, with a royalty-free patent commitment from members [6]) and formal standards bodies (ISO/ASTM 52915 for AMF [8]; ISO/IEC 25422:2025 for 3MF [6]; ISO 10303 for STEP [11]). G-code has no single governing document that all firmwares follow, as the Klipper and Marlin examples show.
Why it matters
Formats decide what information survives each hand-off. A model sent as STL arrives without units or materials; a G-code file sent to the wrong firmware may fail halfway through a print. Choosing formats on purpose is cheaper than debugging their consequences.
In the real world
A common practice is: design in a parametric tool, keep the source, export STEP for CAD collaborators and 3MF or STL for the slicer, and publish the source and a licence together. If a print arrives at the wrong size, suspect units first.
Key terms
- STL — a mesh format of unconnected triangles with no units, colour or metadata.
- 3MF — a ZIP-and-XML format from the 3MF Consortium that carries a mesh, units, metadata and optional extensions.
- AMF — the XML-based additive manufacturing file format standardised as ISO/ASTM 52915.
- STEP — the ISO 10303 family of CAD exchange formats that store exact geometry.
- B-rep — a solid described by its exact bounding surfaces rather than triangles.
- G-code dialect — the set of commands a particular firmware understands.
- Binary G-code — a compact, block-structured G-code format (
.bgcode) defined by Prusa's libbgcode. - OpenVDB — an open-source library for sparse volumetric data on 3D grids.
- Implicit model — a shape defined by a function that says whether each point is inside it.
- Creative Commons licence — a standard set of terms (BY, SA, NC, ND) for reuse of a creative work.
Where this leads
With software and data covered, Part IV leaves the desktop: the materials that feed these machines and the ways to recycle them. Next: Open materials, recycling and distributed manufacturing.