We provide an efficient ready-to-run code gensaw that generates single or large ensembles of self-avoiding, flexible, semiflexible, rotationally isometric or helical chains in the bulk or subject to arbitrary confinement and tethering conditions, where we allow for arbitrary intramolecular bending and dihedral energy functions. The resulting configuration files are provided in various common formats and can be immediately used to do molecular simulations or statistical analysis. We work out analytic expressions for the mean squared end-to-end distance and gyration radius of the semiflexible, helical and rotational isomeric state models with a finite number of bonds and arbitrary interaction potentials for direct comparison and testing of the code in the limiting case of unconfined phantom chains. In addition to the graphics-free linux standalone batch version gensaw that creates configuration and other files for high throughput applications from the command line, we provide an interactive online version gensaw-visualization that serves as platform-independent graphical user interface, and animates the resulting conformations using a remote gensaw server. Program summaryProgram title:gensawCPC Library link to program files:https://doi.org/10.17632/8xfgf88f3w.1Licensing provisions: MITProgramming languages: fortran 90, perl (standalone batch version) or java (interactive online version)Required software:ifort 16+ or gfortran 4+, perl 5+ (standalone batch version), jre 1.8.0+ (interactive online version)Nature of problem: Efficient creation of self-avoiding, semiflexible multibead walks/chains of variable contour length, subject to arbitrary confinement and tethering conditions, characterized by a conformational energy that is composed of arbitrary bending and torsion contributions. The code must produce an ensemble of such chains, using a flexible output format. For the limiting case of chains with zero thickness, the code should reproduce analytic results for the ideal chains.Solution method: We use an adapted enrichment procedure that optimizes its parameters on the fly and derive all analytic results for semiflexible chains with arbitrary bending and torsion potentials for comparison with the created ensembles. While gensaw creates configuration and optionally other files from the command line, gensaw-visualization serves as a platform-independent graphical user interface and allows to visualize and animate the conformations.