MeshView
← All posts

Binary vs ASCII STL: what is the difference?

STL comes in two encodings. Both describe the same triangles, but one is plain text and the other is packed binary data. For printing they are interchangeable. The difference matters for file size, and for software that has to guess which kind it was given.

ASCII STL

An ASCII STL is a text file you can open in any editor. It starts with solid and a name, lists each triangle as a block with its normal and three vertices, and ends with endsolid.

solid part
  facet normal 0 0 1
    outer loop
      vertex 0 0 0
      vertex 1 0 0
      vertex 0 1 0
    endloop
  endfacet
endsolid part

It is easy to read and debug, and it is large. Every number is written out as text, so an ASCII file is typically several times bigger than the binary version of the same model.

Binary STL

A binary STL is compact and has a fixed layout:

  • an 80-byte header, free text that software ignores
  • a 4-byte count of triangles
  • then 50 bytes per triangle: 12 numbers (the normal and three vertices, 4 bytes each) plus 2 spare bytes

So the file size is always 84 plus 50 times the number of triangles. The two spare bytes are called the attribute byte count. Some CAD tools use them to store a colour, but almost no slicer reads it. (STL format overview)

Nearly every modern exporter writes binary STL, because it is smaller and faster to load.

The “solid” trap

The obvious way to tell the encodings apart is to check whether the file starts with the word solid. It does not work reliably. The binary header is free text, and some exporters fill it with a line that begins with solid. A viewer that trusts that first word treats a binary file as text and then fails to read it, often with a message saying the file is empty or corrupt.

The popular 3DBenchy test model is one such file. Its binary header starts with solid, and some viewers reject it for that reason.

A dependable check uses the size instead. Read the triangle count from bytes 80 to 83, and if the file is exactly 84 plus 50 times that count, it is binary. Otherwise treat it as text. MeshView copes with these headers, which is why such files still open.

Does it matter for printing

No. Slicers read both, and a model saved either way prints the same. A few practical points:

  • Pick binary for sharing. The file is smaller and quicker to send over a phone connection.
  • Pick ASCII only to inspect the data or when a tool you rely on needs it.
  • Neither has units or colour. See STL vs 3MF and STL has no units.

If a file will not open

A file that opens nowhere may be truncated. For a binary STL, compare its size to 84 plus 50 times the triangle count: if it is smaller, the download was cut short and you should fetch it again.