This is a simple piece of javascript (licensed under the MIT license) by Alexander Pruss that splits an STL mesh file that contains multiple parts into those multiple parts.

This may well fail if the mesh is defective and has points that are meant to be coincident but are merely close together.

All the processing is done in your browser--your STL is not uploaded to any server.

Warning: If an object has a cavity surrounded by material on all sides, you will get one mesh for the outer surface and an inside-out mesh for the cavity. Solving this problem would require significant coding.