STL file format

STL file is composed of a set of many unordered triangular facets. Its BNF format is defined as followed: STL file has two formats, ASCII format and BINARY format.

The ASCII format is described as followed:

Here is an example of ASCII format STL file:
 
solid sample.stl created by Wei Feng on 15th OCT. 1994 
  facet normal -1.000000 0.000000 0.000000 
    outer loop 
      vertex 140.502634 233.993075 -38.310362 
      vertex 140.502634 229.424780 -38.359042 
      vertex 140.502634 242.525774 -27.097848 
    endloop 
  endfacet 
  facet normal  0.903689 0.004563 0.428166 
    outerloop 
      vertex 134.521310 273.427873 30.342009 
      vertex 134.521310 308.505852 30.715799 
      vertex 140.502634 334.576026 18.369396 
    endloop 
  endfacet 
  facet normal -0.903689 0.004563 0.428166 
    outer loop 
      vertex 140.502634 334.576026 18.369396 
      vertex 140.502634 294.929752 17.946926 
      vertex 134.521310 273.427873 30.342009 
    endloop 
  endfacet 
  ... ... 
endsolid sample.stl
BINARY STL file format is accessed by byte. The format is as follows: the first 80 bytes are used for description, and the next 4 bytes represents the total number of the facets(Long Int), followed by the facet information (normal and 3 vertices), the normal and vertices are stored in floating point format, each occupying 4 bytes. At the end of each facet information section, there are two bytes spaces, then the next facet is repeated till the end of the file. When BINARY format is used to describe STL file, the data size is much smaller than ASCII format, so most STL files available now use BINARY format.  
This page was last updated on 20th Sept. 1997 by Dr. Wei Feng