STXT: Introduction

STXT is a Human-First language, designed for documents and structured data.

Documents

STXT is a format with the following characteristics:

  • Indentation is the structure: no braces or closing tags
  • Free text is literal: no escape characters
  • Schemas with @stxt.template or @stxt.schema: validation and structure written in STXT
  • Safety: safety is not an add-on, it is part of the design of the language

An STXT document combines readability and semantics, which makes it suitable in many fields, for example:

Documents without namespace

# A simple document, with no validation and no namespace
Email:
	From: John Smith
	To: Mery Adams
	Cc: Keyla Brown
	Title: Project report
	# The body is a literal text block
	Body Content >>
		Hello Mery!
		The book is finished!

Documents with namespace and schemas

STXT allows the use of namespaces to group documents. Schemas or templates can also be defined to validate the content of a document.

# An `Email` document from the `com.example.docs` namespace:
Email (com.example.docs):
	From: John Smith <[email protected]>
	To: Mery Adams <[email protected]>
	Cc: Keyla Brown <[email protected]>
	Title: Project report
	Body Content >>
		Hello Mery!!
		The book is finished!!

And the template that validates that namespace:

Template (@stxt.template): com.example.docs
	Structure >>
		Email (com.example.docs):
			From: EMAIL
			To: EMAIL
			Cc: EMAIL
			Bcc: EMAIL
			Title: (?)
			Body Content: (1) TEXT
			Metadata (org.example.meta): (?)

Comparison with other formats

STXT may look like YAML at first sight, but its design is actually closer to XML: sets of nested, ordered text nodes, with namespaces and schemas. Closing tags, attributes, references and entities are removed.

Like YAML, indentation is the structure, but it limits the number of text constructs to two: inline nodes : and text block nodes >>; both without escape characters.

Like NestedText, everything is text. But since it has namespaces, schemas can be defined, which allows validation and semantics without resorting to other languages.

Since the order of the nodes is preserved, no additional notation is needed for lists, because everything is a list.

Where to start

  • Try STXT in the playground
  • Read the tutorial
  • Read the FAQ
  • Install the tools you need: stxt on the command line, the VS Code extension or a library (Java, TypeScript, Python).