Binary vs ASCII STL: The Difference, the Sizes and the 'solid' Trap

Same geometry, different encoding: binary STL uses 50 bytes per triangle, ASCII about five times more. Byte layout, when to use each and the 'solid' trap.

By Updated 6 min read

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)

Binary STL layout: an 80-byte header, a 4-byte triangle count N, then N triangles of 50 bytes each: a 12-byte normal, three 12-byte vertices and 2 attribute bytes

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.

A green 36 mm chess pawn: the binary STL whose header starts with the word solid, opened correctlyView in 3D
A green 36 mm chess pawn: the binary STL whose header starts with the word solid, opened correctly

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.

Frequently asked questions

What is the difference between binary and ASCII STL?

Only the encoding. Both store the same list of triangles with the same precision. Binary uses an 80-byte header, a 4-byte triangle count and 50 bytes per triangle. ASCII spells the same data out as readable text and is roughly five times larger. Every tool reads both.

Should I export STL as binary or ASCII?

Binary, in almost every case. It is smaller, faster to parse and universally supported. Use ASCII only when you need to read or diff the file by hand, or when a specific legacy tool demands it.

Why does my binary STL start with the word solid?

The 80-byte binary header is free-form and some exporters write a description into it that happens to begin with solid, which is also how ASCII files start. Naive parsers that check only the first five bytes then misread the file. Robust parsers compare the file size against 84 plus 50 times the triangle count instead.

How do I convert an ASCII STL to binary?

Open it in any mesh tool and export again with the binary option selected. Blender, MeshLab, FreeCAD, PrusaSlicer and Cura all offer the choice in their STL export dialog. The geometry is unchanged; only the encoding differs.

Is ASCII STL more accurate than binary STL?

No. Both hold float32 numbers. ASCII prints them in decimal, and with the usual seven significant digits it rounds them: in our 10,176-triangle test no vertex moved more than 4.8 nanometres. Nine significant digits give every value back exactly, for a file about 10% larger.

How much bigger is an ASCII STL than a binary STL?

About five times. In our test the same 10,176 triangles took 497 KB as binary and 2.45 MB as ASCII: 50 bytes per triangle against 252. Zipping both narrows the gap to about 1.3 times, but the ASCII file still parsed more than twenty times slower.

Open the 3D viewer

Mes3D on your phone

The Mes3D app for iPhone, iPad and Android opens the same files and adds measuring, mesh analysis, cross-sections and AR. Free to download; some features are paid.

Download on the App StoreGet it on Google Play

More guides

All articles