Tools
PlaygroundVS Code extension
Command line
Libraries
Source code
Everything on this page —playground, extension, command line and libraries— implements the same five specifications and reports the same error codes. Pick a tool for convenience, not for compatibility.
STXT needs no installation to get started. Depending on what you want to do:
| I want to… | Use… |
|---|---|
| Try the language right now, without installing | The playground |
| Write documents every day | The VS Code extension |
Validate from a script, a Makefile or CI |
The stxt command line |
| Read or generate STXT from my own program | A library: TypeScript, Java or Python |
Playground
play.stxt.dev is an editor in the browser, designed as a simplified VS Code: several documents at once, their schemas or templates next to them, syntax and validation errors as you type, grammar-driven autocompletion and hover with the definition of each node.
- Nothing to install and no account to create; your work is kept in the browser itself.
- It comes seeded with example documents to play with and break.
- A document can be shared with a link that carries the content inside.
It is the place to follow the tutorial without leaving the browser.
VS Code extension
The official extension is
STXT – Semantic Text (stxt-lang.stxt).
From the extensions view, searching for stxt, or from the terminal:
code --install-extension stxt-lang.stxt
What it brings:
- Syntax errors in real time, and schema errors when a grammar applies.
- Semantic highlighting driven by the parser itself.
- Completion with the nodes the schema allows and the values of an
ENUM. - Hover information: node, canonical name, type, values and description.
- Go to definition (F12): from a node to the
Node:of its schema, or to its line inside theStructureof its template. - Document formatting.
- Schema and template resolution from the
.stxt/directories of the project, the user and the system, as described in the discovery reference.
Command line
The stxt command is the interface for scripts, Makefiles and continuous
integration pipelines. It is published on npm as
@stxt-lang/cli and requires
Node 20 or newer.
npm install -g @stxt-lang/cli
stxt --version
Or without installing anything permanently:
npx @stxt-lang/cli validate docs/
The commands:
| Command | What it does |
|---|---|
stxt validate |
Parses and validates one or more files or directories; silent when all pass |
stxt format |
Reformats (--tabs / --spaces); --check for CI, --write to save |
stxt describe |
Prints the logical tree of a document as JSON (STXT-TREE-SPEC) |
stxt schemas |
Tells which schemas and templates apply in a directory, and from which level |
stxt install |
Installs a definition into ./.stxt, ~/.stxt or the system level |
A CI example, which fails if any document does not validate or is not well formatted:
stxt validate --recursive docs/
stxt format --check --recursive docs/
The exit code distinguishes your documents have errors from the command was
misused, so it can be used directly from a script. No command rewrites files
without --write.
Libraries
Three implementations, one per ecosystem, with the same scope and the same version. All three derive from the specification through one shared reference pseudocode, and all three pass the same conformance corpus. None of them has runtime dependencies.
TypeScript / JavaScript
@stxt-lang/core on npm. It is
the parser the extension, the command line and the playground run on.
npm install @stxt-lang/core
A minimal example:
import { Parser, InlineNode } from '@stxt-lang/core';
const result = new Parser().parseResult(text);
for (const error of result.getErrors()) {
console.error(`line ${error.line} [${error.code}]: ${error.message}`);
}
const root = result.getNodes()[0];
if (root instanceof InlineNode) {
console.log(root.getChild('Title')?.getText());
}
Java
dev.stxt:stxt-core
on Maven Central. Java 17 or newer; automatic module dev.stxt.
<dependency>
<groupId>dev.stxt</groupId>
<artifactId>stxt-core</artifactId>
<version>0.7.0</version>
</dependency>
Or with Gradle:
implementation 'dev.stxt:stxt-core:0.7.0'
Python
stxt on PyPI. Pure Python, 3.10 or newer.
pip install stxt
A minimal example:
from stxt import Parser, InlineNode
result = Parser().parse_result(text)
for error in result.get_errors():
print(f"line {error.line} [{error.code}]: {error.message}")
root = result.get_nodes()[0]
if isinstance(root, InlineNode):
print(root.get_child("Title").get_text())
Source code
The whole ecosystem lives in the stxt-lang organization on GitHub, under the MIT license:
| Repository | Contents |
|---|---|
| stxt-web | This site: the specifications and the example corpus |
| stxt-js | @stxt-lang/core, the TypeScript library |
| stxt-java | dev.stxt:stxt-core, the Java library |
| stxt-python | stxt, the Python library |
| stxt-cli | @stxt-lang/cli, the command line |
| stxt-vscode | The VS Code extension |
| stxt-play | The playground |
Issues and proposals go to the repository of the tool concerned; those about the
language itself, to stxt-web.