STL Format

The STL or stereo lithography format is an ASCII or binary format used in manufacturing as the main industry standard for the rapid prototyping system. A ".STL" file is a list of x,y,z coordinates representing triangular facets and of the normal vectors to each of them. These triangular facets describe the shape of a closed solid.

ASCII STL format

The structure of the STL ASCII format is the following:

  • The first line must contain the lowercase directive: solid
    This line may optionally contain auxiliary information such as author, date and so on
  • The last line must contain the lowercase directive: endsolid
  • Each block between the first and the last line describes a facet, like in the following example:
       facet normal -1 -1.01506e-016 0
            outer loop
                vertex -53.0978 72.4551 0
                vertex -53.0978 2.45509 0
                vertex -53.0978 2.45509 200
            endloop
        endfacet
    
  • Each block begins with a facet directive, followed by the normal directive and three floating point numeric values representing the components of the outwards normal to the facet, and ends with an endfacet directive.
  • Inside the block, the outer loop and endloop directives define a triangle, by listing its three vertices through the vertex directive followed by the three floating point values of the coordinates.

Binary STL format

The structure of the STL ASCII format is the following:

  • Header: a 80 byte line interpreted as a comment string
  • The total number of facets: 4 bytes (a long integer)
  • Components of the normal and coordinates of the facet vertices: 4 bytes each
  • A 2 byte spacer after each facet.