STL Viewer Online

The STL file format explained

Published · By STL Viewer Online

STL is the oldest file format still in daily use for 3D printing. It was defined in 1987 for the first stereolithography machines (the letters are usually read as "stereolithography") and has not changed since. That is both its strength and the source of every complaint about it: an STL can be read by anything, and an STL can say almost nothing beyond the bare shape. This guide describes what is actually in the file, in both of its encodings, and the consequences for anyone exporting one.

Only triangles

An STL describes a surface as a list of triangles. Each triangle has three corners, given as x, y, z coordinates, and a normal vector that says which side is outside. There is nothing else: no edges, no curves, no information about which triangles are neighbours, no names, no colours, no units. A sphere is a few thousand flat triangles that approximate a sphere; a cube is twelve triangles, two per face. Every other 3D format in use stores more; STL stores this and nothing more.

Two rules make a set of triangles a valid solid. The normal should point outwards, and the corners should be listed counter-clockwise when seen from outside (the right-hand rule), so a reader can work out the outside from the corner order even if the normal is missing or wrong. And every edge should be shared by exactly two triangles, so the surface is closed. Files that break the first rule have flipped normals; files that break the second have holes or non-manifold edges. The format itself does not check either; the slicer finds out later.

The binary layout

Almost every STL you will meet is binary. The layout is fixed and simple:

OffsetSizeContent
080 bytesHeader. Free text, ignored by readers. Should not start with the word "solid" (see below).
804 bytesNumber of triangles, unsigned 32-bit little-endian integer.
8450 bytes per triangleNormal (3 floats), vertex 1 (3 floats), vertex 2 (3 floats), vertex 3 (3 floats), then a 2-byte attribute count, normally zero.

Floats are 32-bit IEEE 754, so each coordinate carries about seven significant digits. The 2-byte attribute field was meant to be followed by extra data per triangle but never was in practice; a couple of vendors have used it to smuggle a colour in, in ways that are not compatible with each other. The file size is therefore exactly 84 + 50 x triangles. A 40 mm cube is 684 bytes. A 100,000-triangle part is 5,000,084 bytes. A 150 MB file is three million triangles, no more and no less, which is a handy way to know what you are about to open.

The ASCII layout

The text form says the same thing in words. This is the complete file for a single triangle:

solid example
  facet normal 0 0 1
    outer loop
      vertex 0 0 0
      vertex 10 0 0
      vertex 0 10 0
    endloop
  endfacet
endsolid example

Every triangle is seven lines. Numbers are written however the exporter likes, often in scientific notation such as 1.000000e+01, which is why an ASCII file of the same model is five to seven times larger than the binary one. ASCII STL is useful when you want to read the file, diff it or generate it from a script, and useless for anything large. The binary to ASCII converter on this site goes either way and tells you which form a file is.

A well-known trap: a binary file whose 80-byte header begins with the text solid. Some exporters write it, some readers check the first five bytes to decide between the two encodings, and the result is a file that one program opens and another rejects. Good readers look at the file length instead: if 84 + 50 x count equals the size, it is binary. This site's viewer does that.

No units

The coordinates in an STL are plain numbers. The format has no field that says what one unit is. The 3D printing world agreed long ago that one unit is one millimetre, and every slicer assumes it, but CAD programs export in whatever the document is set to. A part drawn in inches arrives 25.4 times too small when read as millimetres; a Blender scene in metres arrives 1000 times too small; a program working in centimetres gives a factor of ten. The number is not wrong, it just has no label. The units guide covers how to spot and fix this per program; in short, look at the bounding box in the STL viewer before you slice.

No colour, no materials, no parts

An STL cannot say that a triangle is red, that a region is a different material, or that the file contains two separate objects. Multi-colour and multi-material printing therefore uses 3MF, which was designed for exactly those things, or a set of STL files, one per colour, that happen to be positioned so they fit together. If you export a two-part assembly as one STL you get one file with two shells in it, and nothing in the file records that they were ever separate. The formats guide compares what STL, 3MF, OBJ, STEP and GLB can each hold.

Why files are big

Three reasons. First, every triangle carries its own three corners. A closed mesh has roughly half as many distinct vertices as triangles, and each vertex is shared by about six triangles, so the file writes every point about six times. Formats that index vertices (OBJ, 3MF, GLB, PLY) avoid that. Second, curved surfaces become many small triangles, and the number grows quickly with the export tolerance. Third, the ASCII encoding multiplies everything by five or more.

The tolerance is where you have control. CAD exporters ask, in one form or another, for a maximum deviation (how far a triangle edge may sit from the true curve, sometimes called chord height) and a maximum angle between neighbouring triangles. The right values are related to your printer, not your screen:

SettingCoarseSensible for FDMSensible for resinToo fine
Deviation / chord height0.1 mm0.01 to 0.02 mm0.005 to 0.01 mm0.001 mm
Angle30 degrees5 to 10 degrees2 to 5 degreesunder 1 degree
Typical result for a 50 mm knobVisible flats, 800 trianglesSmooth print, 20,000 trianglesSmooth print, 80,000 trianglesNo visible gain, 2,000,000 triangles, slow slicer

A 0.4 mm nozzle laying 0.2 mm layers cannot reproduce a deviation smaller than about 0.01 mm, so anything finer only makes the file heavier. The viewer in wireframe mode shows the density directly, and the triangle count next to it tells you whether the exporter was set to coarse, sensible or too fine.

Common export gotchas

  • Wrong unit. Covered above. Check the size before slicing, every time, with every new program.
  • Mirrored parts with inverted normals. Mirroring in some tools flips the corner order, so the mirrored half is inside out. The print shows a hollow or missing region. STL repair unifies the normals.
  • Surfaces exported instead of a solid. If the CAD model was a set of surfaces rather than a closed body, the STL is a set of open sheets. The watertight check reports hundreds of open edges. Close the model in CAD; a mesh tool cannot guess the intent.
  • Coincident duplicate vertices. Some exporters write each face separately with tiny differences in shared corners, so triangles that should touch do not. The repair tool merges vertices within a small tolerance and the open-edge count usually drops to zero.
  • Degenerate triangles. Zero-area slivers left by booleans and by very fine tolerances. Harmless in most slicers, fatal in a few; repair removes them.
  • ASCII by default. Some programs (and some versions of others) default to text output. The file is five times larger for no benefit. Choose binary.
  • "solid" in the binary header. Described above. If a tool refuses a file that everything else opens, convert it to binary here and try again.
  • Multiple bodies in one file. Fine for printing in one colour, but the file cannot be split by a slicer into its original parts without a "split to objects" operation, which works only if the shells do not touch.

None of this makes STL a bad format. It is a lowest common denominator, which is useful; everything it does not store, you check yourself.

Questions about this topic

What does an STL file contain?

A list of triangles, each with three corner coordinates and a normal vector. Nothing else: no units, colours, materials, part names or curves.

Is binary or ASCII STL better?

Binary for everything practical: it is five to seven times smaller, faster to load and read by every slicer. ASCII is only useful when you need to read or diff the file as text.

How big is a binary STL file?

Exactly 84 bytes plus 50 bytes per triangle. A 100,000-triangle model is 5,000,084 bytes. Divide the file size minus 84 by 50 to get the triangle count.

Why does my STL have no colour?

The format has no field for it. Use 3MF for multi-colour prints, OBJ or GLB for coloured models in other software, or export one STL per colour.

Related tools

More guides