A polyhedral mesh generation from standard tessellation language (STL) models is presented for the scaled boundary finite element method (SBFEM). The STL format is widely used in 3D printing and computer-aided design (CAD) systems to describe the surface geometry of a 3D object. An STL model for visualisation usually has flaws and is incompatible with mesh generators developed for the finite element method (FEM), such as those found in Abaqus, ANSYS, etc. In this paper, we combine an octreebased polyhedral mesh generation with the SBFEM to perform automatic stress analyses of STL models. As the SBFEM has the capability to model an arbitrary polyhedron by discretising its boundary only, the mesh generation effort is significantly reduced. The basic idea of the proposed method is first creating an octree grid that encloses an STL model and then trimming the grid by the STL surface. The trimming process follows a bottom-up scheme starting from the edges, faces to cells. Within the same framework, a recovery method for sharp features is also developed. It can reconstruct hard edges and points when they are required to be explicitly represented in a mesh. Numerical examples are presented to demonstrate the effectiveness and versatility of the proposed approach. (C) 2016 Elsevier B.V. All rights reserved.