STXT - Semantic Text
Built for humans. Reliable for machines.

AI and LLMs

LLMs generate Markdown effortlessly: it is their mother tongue. But "valid" Markdown means nothing: any output passes, including hallucinated fields, missing sections and broken metadata.

STXT is an ideal format for AI-generated documents:
as easy to write as Markdown, but verifiable.

Why an LLM writes good STXT

STXT does not appear in model training data, but that matters less than it seems. With an example and a template in context, following a regular format is something LLMs do very well.

And STXT is more regular than Markdown:

The possible mistakes are few and well known:

Both are caught at validation time, and that is the key.

The key difference: verifiable

When an LLM generates Markdown, nobody can check the result. When it generates STXT with a template:

A valid STXT document means the structure is correct. Valid Markdown means nothing.

The loop: generate, validate, fix

Validation turns generation into a reliable process:

  1. The LLM generates the STXT document.
  2. The parser validates it against the template.
  3. If there are errors, they are fed back to the model.
  4. The model fixes them and the loop repeats.

With one or two iterations, the success rate approaches 100%. This loop does not exist for Markdown: there is nothing to validate against.

Example of a template included in the prompt:

Template (@stxt.template): com.acme.reports
	Structure >>
		Report (com.acme.reports):
			Title: (1)
			Date: (1) DATE
			Status: (1) ENUM [Draft, Final]
			Summary: (1) TEXT
			Section: (*)
				Title: (1) @Title
				Content: (1) TEXT

Generated output with typical LLM mistakes, all of them caught:

Report (com.acme.reports):
	Title: Market analysis
	Date: tomorrow # ERROR: DATE requires YYYY-MM-DD
	Status: Pending # ERROR: not an ENUM value
	Subtitle: Short version # ERROR: undeclared child (closed model)

No escaping: long prose inside structure

The weak spot of LLMs generating JSON is escaping: quotes, \n, line breaks inside strings.

{"summary": "Line 1\nLine 2 with \"quotes\" and more text..."}

In STXT, >> blocks are literal text: the model only has to indent.

Summary >>
	Line 1
	Line 2 with "quotes" and more text...

For documents with long free text, STXT is a more reliable output surface than JSON or YAML.

Normalization forgives variance

The canonical node name absorbs the usual variations of an LLM: TITLE:, Title: and title: collapse into the same node. Where other formats would say "unknown field", STXT understands it is the same element.

Strict validation is reserved for where it matters: ENUM values are case-sensitive and exact.

Prompting best practices

Use cases

Summary