STL comes in two encodings that describe exactly the same thing. Choosing between them is usually trivial, but the details matter when you are parsing files, diffing them in version control, or debugging one that will not open.
Binary STL, byte by byte
80 bytes header (free-form, usually the exporter's name)
4 bytes uint32: number of triangles
per triangle, 50 bytes:
12 bytes normal vector (3 × float32)
12 bytes vertex 1 (3 × float32)
12 bytes vertex 2 (3 × float32)
12 bytes vertex 3 (3 × float32)
2 bytes attribute byte count (almost always zero)
So a valid binary STL is exactly 84 + 50 × N bytes. That identity is useful:
it lets you verify a file is complete without parsing it, and it means file
size predicts triangle count precisely. A one-million-triangle model is 50 MB,
always.
The two-byte attribute field at the end of each triangle is nominally unused. Some software repurposes it to store a per-triangle colour, in at least two mutually incompatible conventions. Nothing in the standard sanctions this, and most tools ignore the field entirely, so do not rely on colour surviving an STL round trip.
ASCII STL
The same mesh as readable text:
solid name
facet normal 0.0 0.0 -1.0
outer loop
vertex 0.0 0.0 0.0
vertex 20.0 20.0 0.0
vertex 20.0 0.0 0.0
endloop
endfacet
...
endsolid name
Each triangle takes roughly 250–300 bytes depending on how many digits the
exporter writes: 252 bytes in our test file with the common %e style (seven
significant digits) and 276 bytes with nine, against 50 in binary. So ASCII
files run about five to five and a half times larger. The precision is not
better: the numbers are the same float32 values printed in decimal, and with
seven digits they are rounded, by at most 4.8 nanometres in our test. That is
far below anything a printer can show, but it is not more exact.
One model, four files
We saved the same 36 mm chess pawn, 10,176 triangles, four ways and measured each file with three.js's STL loader, the one this site's viewer uses.
| File | Size | Bytes per triangle | vs binary | Zipped | Parse time | Largest rounding |
|---|---|---|---|---|---|---|
| Binary | 497 KB | 50 | 1× | 91 KB | under 1 ms | none |
ASCII, 7 digits (%e) |
2.45 MB | 252 | 5.0× | 122 KB | about 20 ms | 4.8 nm |
| ASCII, 9 digits | 2.68 MB | 276 | 5.5× | 128 KB | about 20 ms | none |
Binary, header starts with solid |
497 KB | 50 | 1× | 91 KB | under 1 ms | none |
What the numbers show:
- Size. ASCII is five times larger with the usual digits, and five and a half times with enough digits to be exact.
- Zip narrows the gap but does not close it. Zipped, the ASCII file is 1.3 times the zipped binary one. This turned pawn repeats many values and compresses unusually well; a scanned or sculpted model compresses far less.
- Parsing. The binary file parsed in under a millisecond and the ASCII ones in about 20 ms, more than twenty times slower. At a million triangles that is the difference between a blink and a pause.
- Precision. Seven significant digits moved no vertex by more than 4.8 nm (0.0000048 mm); nine digits gave back every float32 exactly.
Download the pack, CC BY 4.0:
binary (497 KB),
ASCII, 7 digits (2.45 MB),
ASCII, 9 digits (2.68 MB) and
binary with a solid header (497 KB).
Open two of them in a text editor to see the difference, or drop them into the
viewer to see that they are the same pawn.
The 'solid' trap
The obvious way to detect the format is to check whether the file starts with
solid. This fails, because the 80-byte binary header is free-form and several
exporters write descriptions into it that begin with that exact word.
A parser that only checks the first five bytes will try to read a binary file
as text, find no facet lines, and report an empty or corrupt mesh. The robust
check is arithmetic: read the triangle count at byte 80 and test whether the
file is 84 + 50 × N bytes long. If it is, the file is binary regardless of
what the header says.
This is worth knowing because it explains a specific failure mode — a file that opens fine in one program and appears empty in another is often hitting exactly this.
The fourth file in the test pack is exactly that case: a binary STL whose
header reads solid pawn - binary STL…. Click to open it. The viewer checks the
size first, so it loads as the binary pawn it is.
The size check has one blind spot. A binary file that is cut short, or has
extra bytes at the end, no longer matches 84 + 50 × N; if its header also
starts with solid, even a careful parser falls back to reading it as text.
Exporting the file again fixes it.
Which one to use
Binary, unless you have a reason. It is smaller, parses faster, and every tool written in the last thirty years reads it.
ASCII earns its place in narrow cases:
- Inspecting a file by hand when you suspect bad geometry or a broken exporter.
- Diffing in version control, where a text file produces a meaningful diff and a binary one does not. Note that triangle order is not stable across exports, so even here the diffs are often unhelpful.
- Legacy tooling that only accepts text.
Converting is trivial in either direction: open the file in Blender, MeshLab, FreeCAD or any slicer and export again with the encoding you want. The geometry does not change.
Neither variant fixes STL's real limitations
The encoding choice does not address what STL fundamentally lacks: no units, no reliable colour, no shared vertices, no object structure. If those matter, the answer is a different format rather than a different encoding — see the format comparison and why STL has no units.
Mes3D reads both encodings and detects which one it is given automatically, using the size check rather than the header text.
