Spintax by example

The fastest way to understand spintax is to watch finished text become a template. So we took a real paragraph — the About Spintax block from our own homepage — and reverse-authored it, one technique at a time, exactly the way the reverse-authoring guide describes. Every construct below is coloured the way our editor extensions colour it; every step links to its full guide.

The finished text

Reverse authoring starts from copy you are already happy with, then adds markup last. Here is one sentence of the source — the same words you can read in the About Spintax block:

Spintax is our own template language for producing many genuinely unique variations of a text from a single source you control.

Nothing below invents new wording. We only mark up choices the author already had in mind.

1. A vocabulary of choices

Before touching a sentence, declare the reusable words once. #set re-rolls on every use; #def rolls a value once and keeps it (so a number and its noun stay in step). Edit a line here and every sentence that uses it changes.

#set %Unique% = {genuinely unique|truly distinct|non-repeating}
#set %Engine% = {engine|spintax engine|renderer}
#def %pages% = {1|3|48}

Full guide: Variables →

2. Swap words and whole clauses

The core operator is {a|b|c}. Fork the smallest span that differs — a single word — or a whole opening clause, always leaving the shared tail outside the fork so grammar can never desync.

Spintax {(spin syntax)|— "spin syntax" —} is %OwnLang% for
{producing|generating} many %Unique% variations of a text.

Only the parenthetical differs, so only it is forked — the shared Spintax…is stays outside the braces. Forking the whole {Spintax…is|Spintax…is} would repeat the fixed parts and invite them to drift.

Full guide: Grammar-safe synonymization →

3. Pick and reorder with permutations

A permutation [<…> a|b|c] selects a random subset and shuffles the order — far more variety than stacking synonyms. The feature list below picks three-to-six items each render. The engine list keeps all four and only reorders them — a permutation with no minsize/maxsize includes every item by default, so you set sizes only when the list should vary in length.

It adds [<minsize=3;maxsize=6;sep=", ";lastsep=", and "> permutations|scoped variables|value-driven conditionals|plural agreement|reusable includes|post-processing].

… for [<sep=", ";lastsep=", and "> JavaScript|PHP|Python|Object Pascal]

Full guide: Permutations →

4. Branch on a value

A conditional {?VAR?then|else} chooses by a variable's value, not at random. Toggle one #def and a whole clause changes together.

#def %ai% = {yes|}{?ai?Have an AI draft the template once|Write one template by hand}; the %Engine% then renders unlimited variants.

Full guide: Conditional spintax →

5. Agree with the count

{plural %n%: one|many} picks the right noun form for a number. Because %pages% was a #def, the number and its noun always match — and a plural nests happily inside a permutation.

across [<minsize=1;maxsize=3;sep=", ";lastsep=", or "> %pages% {plural %pages%: page|pages}|dozens of sites|many locales]

Renders 1 page, 3 pages, 48 pages — never "1 pages". Full guide: Plurals →

6. Decline with cases (Russian)

English gets away with one noun form; inflected languages need a different ending in each grammatical case. The move is to pick the entity once and make every case agree with that single pick — hold it in one #def and append the case ending to the stem:

#def %e% = {магазин|сайт|проект}
… о %e%е … для %e%а … к %e%у

Because #def rolls once, the whole sentence stays on one entity — о магазине… для магазина… к магазину. Swap it to #set, which re-rolls at every reference, and the entity teleports mid-sentence — о проекте… для магазина… к сайту: grammatical, nonsense. That contrast is the whole reason to reach for #def. (The stem-plus-ending shortcut works because these three nouns decline alike; a truly irregular noun takes one #def per full form.) Full guide: Grammar-safe (Russian cases) →

The whole template

#set %OwnLang% = {our own template language|a markup language we built|our own template syntax}
#set %Unique% = {genuinely unique|truly distinct|non-repeating}
#set %Source% = {a single source you control|one master you own|a single source of truth}
#set %Engine% = {engine|spintax engine|renderer}
#set %N% = {hundreds|thousands|millions}
#def %ai% = {yes|}
#def %pages% = {1|3|48}

<p>Spintax {(spin syntax)|— "spin syntax" —} is %OwnLang% for {producing|generating} many %Unique% variations of a text from %Source%. You write one template that encodes every choice — [<sep=", ";lastsep=", and "> alternatives|orderings|conditions|variables] — and the %Engine% expands it into %N% of %Unique% variants. {Every variation is one you defined|You define every variation}, so the output stays {on-brand and correct|accurate and on-brand} rather than a probabilistic guess.</p>
<p>The {modern|AI-era} workflow {pairs|combines} a {language model|large language model} with that template logic. {?ai?Have an AI draft the richly varied template once|Write one richly varied template by hand}; the %Engine% then renders {unlimited|endless} variants {locally|on your own hardware}, deterministically, and at near-zero cost.</p>
<p>With spintax you {roll out|publish} %Unique% content across [<minsize=1;maxsize=3;sep=", ";lastsep=", or "> %pages% {plural %pages%: page|pages}|dozens of sites|many locales] — unique by construction, not spun gibberish.</p>
<p>Modern spintax is far more than flat alternation. It adds [<minsize=3;maxsize=6;sep=", ";lastsep=", and "> permutations that pick and order a subset|scoped variables|value-driven conditionals|locale-aware plural agreement|reusable includes|a post-processing pass for spacing and capitalisation].</p>
<p>And it {runs wherever you do|works anywhere you deploy}: four {independent|standalone}, open-source implementations — for [<sep=", ";lastsep=", and "> JavaScript|PHP|Python|Object Pascal] — all held to one shared corpus so a template renders identically on every one.</p>

How it is coloured (the same scopes our editor extensions use):

  • #set directive (#set / #def)
  • {a|b} alternation {a|b}
  • [<…>] permutation [<…> a|b]
  • %VAR% variable %VAR%
  • {?…} conditional {?…}
  • {plural} plural {plural …}

Opens the playground with this template loaded — hit Generate for endless live variants, or edit it.

Get this highlighting in your editor

The colours above are the grammar we ship as editor extensions — install it and your own templates light up the same way: VS Code (301st.spintax) or Sublime Text (Package Control: Spintax).

Where to go next