STL is a file format native to the stereolithography CAD software created by 3D Systems. Chuck Hull, the inventor of stereolithography and 3D Systems’ founder, reports that the file extension is an abbreviation for stereolithography.
An STL file describes a raw, unstructured triangulated surface by the unit normal and vertices (ordered by the right-hand rule) of the triangles using a three-dimensional Cartesian coordinate system. In the original specification, all STL coordinates were required to be positive numbers, but this restriction is no longer enforced and negative coordinates are commonly encountered in STL files today. STL files contain no scale information, and the units are arbitrary. STL files describe only the surface geometry of a three-dimensional object without any representation of color, texture or other common CAD model attributes. The STL format specifies both ASCII and binary representations. Binary files are more common, since they are more compact.
STL is widely used for rapid prototyping, 3D printing and computer-aided manufacturing, and supported by many other software packages.
History
STL was invented by the Albert Consulting Group for 3D Systems in 1987. The format was developed for 3D Systems' first commercial 3D printers. Since its initial release, the format remained relatively unchanged for 22 years.
In 2009, an update to the format, dubbed STL 2.0, was proposed which evolved into the Additive manufacturing file format.
Format
ASCII
An ASCII STL file begins with the line:
solid name
where name is an optional string (though if name is omitted there must still be a space after solid, for compatibility with some software). The remainder of the line is ignored and is sometimes used to store metadata (e.g., filename, author, modification date, etc). The file continues with any number of triangles, each represented as follows:
facet normal ni nj nk
outer loop
vertex v1x v1y v1z
vertex v2x v2y v2z
vertex v3x v3y v3z
endloop
endfacet
where each n or v is a floating-point number in sign-mantissa-e-sign-exponent format, e.g., 2.648000e-002. The file concludes with:
endsolid name
The structure of the format suggests that other possibilities exist (e.g., facets with more than one loop, or loops with more than three vertices). In practice, however, all facets are simple triangles.
Whitespace (spaces, tabs, newlines) may be used anywhere in the file except within numbers or words. The spaces between facet and normal and between outer and loop are required.
Binary
Because ASCII STL files can be very large, a binary version of STL exists. A binary STL file has an 80-character header which is generally ignored, but should never begin with the ASCII representation of the string solid, as that may lead some software to confuse it with an ASCII STL file. Following the header is a 4-byte little-endian unsigned integer indicating the number of triangular facets in the file. Following that is data describing each triangle in turn. The file simply ends after the last triangle.
Each triangle is described by twelve 32-bit floating-point numbers: three for the normal and then three for the X/Y/Z coordinate of each vertex – just as with the ASCII version of STL. After these follows a 2-byte ("short") unsigned integer that is the "attribute byte count" – in the standard format, this should be zero because most software does not understand anything else.
Floating-point numbers are represented as IEEE floating-point numbers and are assumed to be little-endian, although this is not stated in documentation.
UINT8[80] – Header - 80 bytes
UINT32 – Number of triangles - 4 bytes
foreach triangle - 50 bytes: REAL32[3] – Normal vector - 12 bytes REAL32[3] – Vertex 1 - 12 bytes REAL32[3] – Vertex 2 - 12 bytes REAL32[3] – Vertex 3 - 12 bytes UINT16 – Attribute byte count - 2 bytes end
There are at least two non-standard variations on the binary STL format for adding color information: