Writers create passages and link them, and Twine builds a map of the story. Output is an HTML file that runs in a browser. Story formats like Harlowe and SugarCube add variables and logic.
It is free and open source, though advanced features need some scripting.
Ink and Yarn Spinner are alternatives. Twine suits game writers sketching branching narratives.