A JavaScript library for generating text and stories using context-free grammars and rule-based expansion.
Tracery is a JavaScript library for generating text and stories using context-free grammars defined in JSON. It allows developers to create dynamic, rule-based narratives by expanding symbols and applying modifiers, enabling procedural content generation for games, bots, and interactive experiences.
Creative coders, game developers, writers, and artists looking to incorporate generative text or procedural storytelling into web projects, games, or interactive installations.
Tracery offers a simple yet powerful grammar system that is easy to learn and implement, with no dependencies, making it a go-to choice for lightweight, flexible text generation in JavaScript environments.
Tracery: a story-grammar generation library for javascript
Rules are defined in simple JSON format, enabling quick creation and iteration of generative text without complex coding, as shown in the example grammar structure.
Supports built-in modifiers like .capitalize and .s for pluralization, allowing for rich text transformations directly within rules, enhancing output variety.
Works natively in browsers and has a community-maintained Node.js port (v21/tracery), making it versatile for both client-side and server-side use.
Provides Trace objects for step-by-step expansion and flattening, useful for debugging or creating interactive experiences where expansion process matters.
The Node.js library is maintained by a community member (George Buckenham), which may lead to version mismatches or delayed updates compared to the core browser library.
As a context-free grammar system, it doesn't natively support persistent state or dynamic variable changes during generation, restricting complex branching narratives.
The README primarily points to external editors and tutorials, lacking comprehensive API documentation or best practices, relying on community resources.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.