# SugarCube

Twine/Twee story format with macros, state history, configurable saves and JavaScript integration\.

ID: Q175 · Revision: 159

Type: software · License: BSD\-2\-Clause story format; authored content and third\-party assets have separate terms[^license] · Status: active

Website: https://www.motoslave.net/sugarcube/2/



SugarCube is a story format for Twine and compatible Twee workflows\. It supplies browser runtime behavior for linked passages, macros, variables and saved state, while authoring can take place in an editor or a compiler\-based project\. Its state model and extension interfaces are specific to the format, so switching from another Twine format involves more than choosing a different visual theme\.[^home][^script][^migration]

## Capabilities and substitutions

### Persistent and temporary variables — supported

Story variables enter history; temporary variables last only for their moment or turn\.[^script]

Use case: Runtime for stateful choice\-based Twine stories · Platforms: Twine/Twee authoring tools, Modern web browsers · Region: Version, build and integration requirements apply

### Save\-state capture — limited

Saves preserve navigation\-created moments, not necessarily every change made within the displayed passage\.[^state]

Use case: Runtime for stateful choice\-based Twine stories · Platforms: Twine/Twee authoring tools, Modern web browsers · Region: Version, build and integration requirements apply

### Save methods — supported

The API documents browser auto/slot, disk and Base64 saves, with browser\-storage caveats\.[^saves]

Use case: Runtime for stateful choice\-based Twine stories · Platforms: Twine/Twee authoring tools, Modern web browsers · Region: Version, build and integration requirements apply

### Debugging views — limited

Test mode adds markup that can alter nested markup or selectors; release output also needs testing\.[^testing]

Use case: Runtime for stateful choice\-based Twine stories · Platforms: Twine/Twee authoring tools, Modern web browsers · Region: Version, build and integration requirements apply

### [Substitute for Chapbook](/chapbook) — limited

Can replace Chapbook as a Twine runtime for new stateful choice stories, especially when nested conditional macros and configurable save APIs are desired\. Syntax and persistence assumptions require adaptation\.[^script][^saves][^chapbook]

Use case: Runtime for stateful choice\-based Twine stories · Platforms: Twine/Twee authoring tools, Modern web browsers · Region: Version, build and integration requirements apply

## References

[^home]: [SugarCube overview](<https://www.motoslave.net/sugarcube/2/>) — Twine/Twee format, browser requirements and format\-specific add\-ons (vendor; retrieved 2026-10-07T21:01:27Z)

[^script]: [SugarCube TwineScript reference](<https://github.com/tmedwards/sugarcube-2/blob/master/docs/core/twinescript.md>) — Story versus temporary variables, expressions and serializable state constraints (vendor; retrieved 2026-10-07T21:03:59Z)

[^state]: [State, sessions and saving](<https://github.com/tmedwards/sugarcube-2/blob/master/docs/guides/guide-state-sessions-and-saving.md>) — Navigation moments, session storage and replacement on load (vendor; retrieved 2026-10-07T21:02:42Z)

[^saves]: [SugarCube Save API](<https://github.com/tmedwards/sugarcube-2/blob/master/docs/api/api-save.md>) — Browser, disk and Base64 save types; private browsing warning (vendor; retrieved 2026-10-07T21:03:36Z)

[^testing]: [SugarCube test mode](<https://github.com/tmedwards/sugarcube-2/blob/master/docs/guides/guide-test-mode.md>) — Debug wrappers, variable watches and history navigation (vendor; retrieved 2026-10-07T21:02:53Z)

[^media]: [SugarCube media passages](<https://github.com/tmedwards/sugarcube-2/blob/master/docs/guides/guide-media-passages.md>) — Embedded media, Tweego support and Twine 2 size warning (vendor; retrieved 2026-10-07T21:03:53Z)

[^migration]: [Harlowe\-to\-SugarCube guide](<https://github.com/tmedwards/sugarcube-2/blob/master/docs/guides/guide-harlowe-to-sugarcube.md>) — Macro arguments, containers, DOM targeting and goto behavior (vendor; retrieved 2026-10-07T21:02:42Z)

[^license]: [SugarCube license](<https://github.com/tmedwards/sugarcube-2/blob/master/LICENSE>) — Two\-clause redistribution terms and disclaimer (vendor; retrieved 2026-10-07T21:02:53Z)

[^chapbook]: [Chapbook conditional display](<https://klembot.github.io/chapbook/guide/en/state/conditional-display.html>) — Explicit comparison with SugarCube nested conditions (vendor; retrieved 2026-10-07T21:01:45Z)

Source revision: https://substitutefor.net/entities/Q175?revision=159
