How to repair an STL file

To repair an STL, you close its holes, flip faces that point inward and remove stray faces, so your slicer sees one sealed shell. Blender does all of it for free with a few menu commands. On a test file we broke on purpose, the steps fixed all 98 broken edges.

pyrofx effects work today, and new accounts start with $5 of usage.

Before repair, the test head has a hole in the scalp and a patch of red inward faces on the cheek. After meshfx repair, every face is blue.
Blue shows the outside of a face and red the inside. After repair, the red cheek faces point out again and the hole in the scalp is closed.

What a broken STL file looks like

An STL file is just a list of triangles, with no textures, colors or units. Each triangle saves its own three corners, so the file never says which triangles touch. Your slicer has to work that out, and it fails when the surface has gaps or edges that don't line up.

A printable model is watertight, meaning it's one sealed shell. Every edge is shared by exactly two faces, and edges that break that rule are called non-manifold. Every face also has to point outward. Four common faults break these rules, and most broken files have more than one.

Four faults sit side by side: a hole ringed by open edges, a face that points inward, an edge shared by three faces and two unwelded corners.
Each fault has its own fix in Blender, so find out which ones your file has before you change anything.

We broke a test file, then fixed it

We took Blender's monkey head and broke it on purpose. We punched two holes in it, flipped 29 faces on one cheek inside out and stuck a stray triangle onto one edge. Then we saved it as an STL.

We ran the broken file through meshfx with its default repair and compared the reports from before and after.

CheckBroken STLAfter meshfx repair
Triangles3,9303,985
Holes40
Inside-out faces290
Edges with an extra face10
Open edges9735
Separate parts34

Two of the 4 holes were ours. The other 2 are the eye sockets, which are open in Blender's original head. The 35 open edges left belong to the eyeballs, which are open by design, and to the stray triangle. The repair split that triangle off as its own part.

meshfx checks every repair step against the original surface. None of the steps moved it enough to be undone.

Our test STL stores 3,930 triangles as 11,790 corners, which weld to 2,013 vertices, in a file of 84 + 3,930 × 50 = 196,584 bytes.
STL saves every corner of every triangle on its own, so shared corners repeat and the file never says which triangles connect.

How to repair an STL in Blender

  1. Import the file with File, then Import, then STL. Select it and press Tab to enter Edit Mode.
  2. Press A to select everything, then press M and choose By Distance to weld corners that should be joined. On our test file it removed nothing, because the importer already joins exact matches. On files with tiny gaps, it closes the cracks.
  3. Press Alt+A to deselect, press 2 to select edges, then choose Select, then Select All by Trait, then Non Manifold. Blender highlights every problem edge. On our file, it found 119, including the edges around the flipped faces.
  4. Press A, then choose Mesh, then Clean Up, then Fill Holes. In the Adjust Last Operation panel, set Sides to 0 so it fills holes of any size. On our file, only 2 open edges were left.
  5. Turn on Face Orientation in the Viewport Overlays menu. Blue faces point out and red faces point in. Press A, then Shift+N to make every face point out. The 29 red faces turned blue.
  6. Run Select Non Manifold again. Click any face still attached to a highlighted edge, like the stray triangle here, press X and choose Faces. Repeat until nothing is highlighted.
  7. Export with File, then Export, then STL. Our fixed file had 0 open edges and 0 non-manifold edges.
Four Blender steps change the test file's counts: 119 edges selected, open edges from 97 to 2, flipped-face edges from 21 to 0 and three-face edges from 1 to 0.
Four Blender steps took the test file to zero faults. Each panel shows what that step fixed.

Which fix each STL fault needs

FaultHow you spot itBlender fix
HoleSelect Non Manifold highlights a ring of open edgesMesh, then Clean Up, then Fill Holes with Sides at 0. Or select the ring and press F.
Inside-out facesRed patches with Face Orientation onSelect all, then Shift+N
Non-manifold edgeAn edge stays highlighted after you fill holesDelete the extra face, or split it off with P
Unwelded cornersCracks along edges, or far more vertices than you expectM, then By Distance
Parts that crossShapes pass through each other and the slicer shows extra wallsA Boolean union, or the Remesh modifier set to Voxel
Thin wallsWalls thinner than your nozzle disappear in the slicer previewA Solidify modifier

Repair STL files with meshfx

meshfx reads STL, OBJ, PLY and glTF files. It finds holes, inside-out faces and non-manifold edges, then repairs them one step at a time. After each step it compares the result with your original and undoes any step that changes the shape too much. The before and after numbers came from its report. Hosted meshfx runs are available in the Playground.

meshfx writes GLB files for Godot, Unity, Unreal, Roblox and three.js, not STL. To print, open the repaired GLB in Blender and export it as STL.

STL files don't say which way is up. Files from Blender and most CAD tools use Z as up, so set up = "z" in your spec, or the model lands on its back.

monkey.meshfx.toml
[source]
file = "monkey_broken.stl"

# STL from Blender is Z up.
[units]
up = "z"

# Keep every triangle and run the default repair.
[simplify]
triangles = 0

[uv]
mode = "keep"

[bake]
source_detail = false

[collision]
mode = "none"

[export]
targets = ["godot"]

To fail the run when a fault survives repair, add fail_on = ["OPEN_HOLES", "NON_MANIFOLD_EDGES"] under [budget]. Every key is in the meshfx spec reference.

Let your agent repair the STL

Paste this prompt into Claude Code, Cursor or Codex. Your agent connects to Spatial Compiler and comes back with a repaired GLB and a report of the holes, flipped faces and non-manifold edges before and after.

New accounts start with $5 of usage, and you see the price of each job before it runs.

Give this to your agent

Connect the Spatial Compiler MCP server at https://spatialcompiler.dev/mcp if it isn't connected yet. Use meshfx to repair my STL file and give me the repaired GLB. Show me the price before it runs.

Or add the server yourself in Claude Code:

claude mcp add --transport http spatial-compiler https://spatialcompiler.dev/mcp

Set it up in Cursor, Codex or another agent

Questions about repairing STL files

All questions →

README.REPAIR_STL
How do I repair an STL file in Blender?

Import it, select non-manifold edges, fill holes with Sides set to 0, press Shift+N to fix flipped faces, delete stray faces and export. If the file has cracks, weld corners first with M, then By Distance.

How do I repair an STL file for 3D printing?

Make it watertight, meaning one sealed shell with every face pointing out. Fill holes, fix flipped faces and remove extra faces, then check that thin walls don't disappear in your slicer.

How do I clean up an STL in Blender?

Weld corners with M, then By Distance. Then use Mesh, then Clean Up, then Delete Loose to remove stray points, and Degenerate Dissolve to remove faces with no area. Fill holes and fix normals last.

What is a free tool for repairing STL files?

Blender is free and covers every fix: Select Non Manifold, Fill Holes, Recalculate Outside and Merge by Distance. Most slicers also repair small holes and flipped faces on their own when you import.

Can I repair an STL file online?

Yes, several sites repair STL files in the browser. They fix holes and flipped faces automatically, but they don't show you what changed. Check the result in Blender with Face Orientation and Select Non Manifold before you print.

Why isn't Blender recognizing my STL file?

Use File, then Import, then STL, because File, then Open only reads .blend files. If it imports and you can't see it, it may be tiny or huge, since STL has no units. Press Numpad period to zoom to it.

Can AI repair STL files?

Automatic repair tools can. They follow fixed rules, since a hole is either closed or open and a face points out or in. meshfx runs those rules on STL files, measures the result and writes GLB.