Search by

jaizendra-netizen / spintax-validator

onegtmlab

PHP CLI and library: check spintax in cold email copy for unbalanced braces, empty options, one-option groups and deep nesting, and count the variants.

Package info

github.com/jaizendra-netizen/spintax-validator

Homepage

Type:project

pkg:composer/jaizendra-netizen/spintax-validator

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-11-28 22:38 UTC

This package is not auto-updated.

Last update: 2026-11-29 21:02:49 UTC


README

PHP command line tool and library. Give it a text file with one cold email line or message per line, written with spintax such as {Hi|Hello} {there|friend}, and it checks each message for unbalanced braces (it says which brace and at which column), empty options such as {a||b}, groups with a single option such as {a}, and nesting deeper than 3. For every valid message it counts the variants: the options of a group add up, groups in a row multiply, and nested groups are counted inside their option. The count is of option combinations, so two identical options count as two.

Part of the OneGTMLab free GTM tools. Background on the idea: spintax.

Install

composer require jaizendra-netizen/spintax-validator

Use

Input is a text file, one message per line (blank lines are skipped). Use --whole to read the whole file as one message. There is no escape syntax, so every { and } is read as a group delimiter, which means double-brace merge tags such as {{first_name}} are reported as errors; check the copy before you add merge tags. The command exits 1 if any message has an error, so it can gate a send; the example below prints the exit code after the report. Unreadable files and bad arguments exit 2.

$ php bin/spintax-validator sample.txt; echo "exit code: $?"
line 1: OK, 6 variants
line 2: OK, 8 variants
line 3: OK, 2 variants
line 4: ERROR, empty option in group opened at column 13
line 5: ERROR, unclosed { at column 4
line 6: OK, 6 variants
exit code: 1

Test

php tests/run.php

Offline, no network calls, no dependencies beyond the language runtime. MIT licensed.