The StL Format

Standard Data Format for Fabbers

Reprinted from Section 6.5 of
Automated Fabrication by Marshall Burns, Ph.D.
Used with permission.

Technical source:
StereoLithography Interface Specification, 3D Systems, Inc., October 1989

Page contents:
        Format Specifications
        StL ASCII Format
        StL Binary Format

Copyright © 1993, 1999, Ennex Research Corporation. All rights reserved.


An StL (“StereoLithography”) file is a triangular representation of a 3-dimensional surface geometry. The surface is tessellated or broken down logically into a series of small triangles (facets). Each facet is described by a perpendicular direction and three points representing the vertices (corners) of the triangle. These data are used by a slicing algorithm to determine the cross sections of the 3-dimensional shape to be built by the fabber.

This Web page describes the technical details of the StL file format. Most fabber users do not need to be concerned with this. It is provided here for those who are interested in developing hardware or software that will read or write StL files.

Format Specifications

An StL file consists of a list of facet data. Each facet is uniquely identified by a unit normal (a line perpendicular to the triangle and with a length of 1.0) and by three vertices (corners). The normal and each vertex are specified by three coordinates each, so there is a total of 12 numbers stored for each facet.

Facet orientation in an StL file
Orientation of a facet is determined by the direction of the unit normal and the order in which the vertices are listed.

Facet orientation. The facets define the surface of a 3-dimensional object. As such, each facet is part of the boundary between the interior and the exterior of the object. The orientation of the facets (which way is “out” and which way is “in”) is specified redundantly in two ways which must be consistent. First, the direction of the normal is outward. Second, the vertices are listed in counterclockwise order when looking at the object from the outside (right-hand rule). These rules are illustrated in Figure 1.

Vertex-to-vertex rule. Each triangle must share two vertices with each of its adjacent triangles. In other words, a vertex of one triangle cannot lie on the side of another. This is illustrated in Figure 2.

Vertex-to-vertex rule in an StL file
The vertex-to-vertex rule. The left figure shows a violation of the rule. A correct configuration is shown on the right.

The object represented must be located in the all-positive octant. In other words, all vertex coordinates must be positive-definite (nonnegative and nonzero) numbers. The StL file does not contain any scale information; the coordinates are in arbitrary units.

The official 3D Systems StL specification document states that there is a provision for inclusion of “special attributes for building parameters,” but does not give the format for including such attributes. Also, the document specifies data for the “minimum length of triangle side” and “maximum triangle size,” but these numbers are of dubious meaning.

Sorting the triangles in ascending z-value order is recommended, but not required, in order to optimize performance of the slice program.

Typically, an StL file is saved with the extension “StL,” case-insensitive. The slice program may require this extension or it may allow a different extension to be specified.

The StL standard includes two data formats, ASCII and binary. These are described separately below.

StL ASCII Format

The ASCII format is primarily intended for testing new CAD interfaces. The large size of its files makes it impractical for general use.

The syntax for an ASCII StL file is as follows:

Data structure for StL ASCII format

Bold face indicates a keyword; these must appear in lower case. Note that there is a space in “facet normal” and in “outer loop,” while there is no space in any of the keywords beginning with “end.” Indentation must be with spaces; tabs are not allowed. The notation, “{…}+,” means that the contents of the brace brackets can be repeated one or more times. Symbols in italics are variables which are to be replaced with user-specified values. The numerical data in the facet normal and vertex lines are single precision floats, for example, 1.23456E+789. A facet normal coordinate may have a leading minus sign; a vertex coordinate may not.

StL Binary Format

The binary format uses the IEEE integer and floating point numerical representation.

The syntax for a binary StL file is as follows:

Data structure for StL binary format

The notation, “{…}+,” means that the contents of the brace brackets can be repeated one or more times. The attribute syntax is not documented in the formal specification. It is specified that the attribute byte count should be set to zero.