STL Stereolithography
The STL 3D model format — the standard for 3D printing, representing surface geometry as a mesh of triangles in either ASCII or binary encoding.
You are a file format specialist with deep expertise in STL (Stereolithography), including ASCII and binary format internals, triangle mesh geometry, watertight mesh validation, repair workflows with MeshLab and admesh, and 3D printing slicer integration. ## Key Points - **Extension:** `.stl` - **MIME type:** `model/stl` - **Variants:** ASCII (human-readable) and Binary (compact) - **Geometry:** Triangulated surface mesh only - **Normal vectors:** One per triangle (often ignored by software, recomputed from vertex order) - **Vertex order:** Counter-clockwise when viewed from outside (right-hand rule) - Normal vector (3 x float32 = 12 bytes) - Vertex 1 (3 x float32 = 12 bytes) - Vertex 2 (3 x float32 = 12 bytes) - Vertex 3 (3 x float32 = 12 bytes) - Attribute byte count (uint16 = 2 bytes, usually 0) - **3D printing:** The de facto standard for sending models to FDM, SLA, and SLS printers ## Quick Example ```bash meshlab model.stl # MeshLab (cross-platform) f3d model.stl # F3D viewer # Online: ViewSTL.com, GitHub renders STL natively ```
skilldb get file-formats-skills/STL StereolithographyFull skill: 218 linesYou are a file format specialist with deep expertise in STL (Stereolithography), including ASCII and binary format internals, triangle mesh geometry, watertight mesh validation, repair workflows with MeshLab and admesh, and 3D printing slicer integration.
STL Stereolithography (.stl)
Overview
STL (Standard Tessellation Language, originally STereoLithography) is a 3D file format created by 3D Systems in 1987 for their stereolithography CAD software. It describes the surface geometry of a 3D object using triangular facets — nothing more. No colors, no textures, no materials, no animation. This simplicity made it the universal standard for 3D printing, where slicing software needs only the surface mesh to generate toolpaths.
Despite its age and limitations, STL remains the dominant format in the 3D printing ecosystem.
Core Philosophy
STL (Stereolithography) describes 3D geometry using the simplest possible representation: a list of triangles defined by their vertices and surface normals. There are no colors, no materials, no textures, no scene hierarchy — just triangles. This extreme simplicity made STL the standard for 3D printing when the technology emerged in the 1980s, and it remains the most widely supported format for additive manufacturing despite its severe limitations.
STL's philosophy is that mesh geometry alone is sufficient for manufacturing. A 3D printer ultimately needs to know only the surface boundary of the object to generate toolpaths, and STL provides exactly that. This was a reasonable assumption for early single-material, single-color 3D printers. Modern multi-material, full-color printers need information STL cannot provide, which is why 3MF was created as its successor.
For 3D printing, use STL when your slicer or printer requires it, but prefer 3MF when supported. For any other 3D interchange purpose (game assets, web 3D, visualization, animation), STL is the wrong choice — use glTF, FBX, or OBJ, which support materials, textures, and richer scene descriptions. STL's role is narrow: getting geometry from a CAD system to a 3D printer slicer.
Technical Specifications
- Extension:
.stl - MIME type:
model/stl - Variants: ASCII (human-readable) and Binary (compact)
- Geometry: Triangulated surface mesh only
- Normal vectors: One per triangle (often ignored by software, recomputed from vertex order)
- Vertex order: Counter-clockwise when viewed from outside (right-hand rule)
ASCII Format
solid name
facet normal ni nj nk
outer loop
vertex v1x v1y v1z
vertex v2x v2y v2z
vertex v3x v3y v3z
endloop
endfacet
facet normal ...
...
endfacet
endsolid name
Binary Format
[Header (80 bytes, arbitrary text)]
[Number of triangles (4 bytes, uint32)]
[Triangle 1 (50 bytes)]
- Normal vector (3 x float32 = 12 bytes)
- Vertex 1 (3 x float32 = 12 bytes)
- Vertex 2 (3 x float32 = 12 bytes)
- Vertex 3 (3 x float32 = 12 bytes)
- Attribute byte count (uint16 = 2 bytes, usually 0)
[Triangle 2 (50 bytes)]
...
Binary STL file size = 84 + (50 x number of triangles) bytes.
How to Work With It
Viewing
meshlab model.stl # MeshLab (cross-platform)
f3d model.stl # F3D viewer
# Online: ViewSTL.com, GitHub renders STL natively
Creating
# Python with numpy-stl
import numpy as np
from stl import mesh
# Create a simple cube
vertices = np.array([
[0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0], # bottom
[0, 0, 1], [1, 0, 1], [1, 1, 1], [0, 1, 1], # top
])
faces = np.array([
[0,3,1], [1,3,2], # bottom
[4,5,7], [5,6,7], # top
[0,1,4], [1,5,4], # front
[2,3,6], [3,7,6], # back
[0,4,3], [3,4,7], # left
[1,2,5], [2,6,5], # right
])
cube = mesh.Mesh(np.zeros(faces.shape[0], dtype=mesh.Mesh.dtype))
for i, f in enumerate(faces):
for j in range(3):
cube.vectors[i][j] = vertices[f[j],:]
cube.save('cube.stl')
# OpenSCAD (programmatic CAD)
echo 'cube([10, 10, 10]);' > cube.scad
openscad -o cube.stl cube.scad
# Blender CLI export
blender model.blend --background --python-expr "
import bpy
bpy.ops.wm.stl_export(filepath='output.stl')
"
Converting
# STL to OBJ
meshlabserver -i model.stl -o model.obj
# STL to 3MF (better for 3D printing)
# Use PrusaSlicer, Cura, or Blender
# ASCII to Binary (saves ~80% file size)
python3 -c "
import numpy as np
from stl import mesh
m = mesh.Mesh.from_file('ascii.stl')
m.save('binary.stl', mode=mesh.Mode.BINARY)
"
Repairing and Processing
# MeshLab CLI — repair common issues
meshlabserver -i broken.stl -o fixed.stl \
-s repair_script.mlx
# Admesh — dedicated STL repair tool
admesh --remove-unconnected --fill-holes --normal-values model.stl -o fixed.stl
# Python — check if mesh is watertight
import trimesh
mesh = trimesh.load('model.stl')
print(f"Watertight: {mesh.is_watertight}")
print(f"Volume: {mesh.volume}")
Common Use Cases
- 3D printing: The de facto standard for sending models to FDM, SLA, and SLS printers
- Rapid prototyping: Quick geometry exchange between CAD and manufacturing
- CNC machining: Surface geometry for CAM toolpath generation
- Medical imaging: CT/MRI scan data converted to 3D printable models
- Finite element analysis: Surface meshes for simulation pre-processing
- Quality inspection: 3D scanning outputs for comparison with CAD models
Pros & Cons
Pros
- Universal 3D printing support — every slicer and 3D printer accepts STL
- Extremely simple format, trivial to parse and generate
- Binary variant is compact and fast to read/write
- No ambiguity — triangles only, no complex geometry primitives
- Supported by virtually all CAD, 3D modeling, and engineering software
- GitHub and many platforms render STL files in-browser
Cons
- No color, texture, or material information (some tools abuse the attribute bytes for color)
- No units specified in the format — must be agreed upon externally
- No topology — vertices are duplicated across triangles (no shared vertex indices)
- No support for curves, NURBS, or parametric geometry (tessellation only)
- ASCII variant is extremely verbose and slow to parse
- Cannot represent assemblies or multiple distinct objects (no hierarchy)
- Being slowly replaced by 3MF for modern 3D printing workflows
Compatibility
| Software | Import | Export | Notes |
|---|---|---|---|
| All 3D print slicers | Yes | N/A | Cura, PrusaSlicer, Simplify3D, etc. |
| SolidWorks | Yes | Yes | Primary 3D printing export |
| Fusion 360 | Yes | Yes | Full support |
| Blender | Yes | Yes | Import/export add-on |
| FreeCAD | Yes | Yes | Full support |
| OpenSCAD | Export | Yes | Programmatic CAD output format |
| MeshLab | Yes | Yes | Mesh processing reference tool |
Programming languages: Python (numpy-stl, trimesh, meshio), JavaScript (three.js STLLoader), C++ (Assimp, CGAL), Rust (stl_io), Go (stl packages), Java (Apache Commons STL).
Related Formats
- 3MF — Modern replacement with colors, materials, units, and multi-object support
- OBJ — Adds texture coordinates and materials, also widely supported
- AMF — Additive Manufacturing File Format (XML-based, didn't gain traction)
- PLY — Adds vertex colors and properties, used in 3D scanning
- STEP — Full CAD format with parametric geometry (not mesh-based)
- glTF — Modern web 3D format with PBR materials
Practical Usage
- Always use binary STL for production workflows -- it is ~80% smaller than ASCII STL and much faster to read/write.
- Validate mesh watertightness with
trimesh(Python) oradmeshbefore sending to a 3D printer -- non-manifold meshes, holes, and flipped normals cause print failures. - Use
admesh --remove-unconnected --fill-holesfor quick automated mesh repair of common STL issues. - Consider 3MF as a modern replacement for STL when your slicer supports it -- 3MF includes units, colors, materials, and multi-object support that STL lacks.
- When exporting from CAD software, control the tessellation quality (chord tolerance) to balance file size against surface smoothness for your application.
- Use
numpy-stl(Python) for programmatic STL generation and analysis -- it provides fast NumPy-based mesh operations.
Anti-Patterns
- Using ASCII STL for large models -- ASCII STL is extremely verbose; a 1-million-triangle model is ~50 MB in binary but ~250 MB in ASCII.
- Assuming STL files specify units -- STL has no unit declaration; the same file could be interpreted as millimeters, inches, or meters depending on the software. Always confirm units with the source.
- Relying on STL normal vectors for geometry -- Most software ignores the stored normals and recomputes them from vertex winding order; do not store critical data in the normal fields.
- Using STL for models requiring color, texture, or material information -- STL has no standard support for these; use 3MF, OBJ, or glTF instead.
- Sending STL files directly to CNC machines -- STL is a tessellated approximation, not exact geometry; use STEP for CNC machining where dimensional accuracy matters.
Install this skill directly: skilldb add file-formats-skills
Related Skills
3MF 3D Manufacturing Format
The 3MF file format — the modern replacement for STL in 3D printing, supporting colors, materials, multi-object assemblies, and precise manufacturing data in a single package.
7-Zip Compressed Archive
The 7z archive format — open-source high-ratio compression using LZMA2, with strong AES-256 encryption, solid archives, and multi-threading support.
AAC (Advanced Audio Coding)
A lossy audio codec standardized as part of MPEG-2 and MPEG-4, designed to supersede MP3 with better quality at equivalent or lower bitrates.
AC3 (Dolby Digital)
Dolby's surround sound audio codec used in cinema, DVD, Blu-ray, and broadcast television for multichannel 5.1 audio delivery.
AI Adobe Illustrator Format
AI is Adobe Illustrator's native vector graphics file format, used for
AIFF (Audio Interchange File Format)
Apple's uncompressed audio format storing raw PCM data, serving as the Mac equivalent of WAV for professional audio production.