Early developmentPre-1.0: syntax may change.Release historyGitHub

Language essentials

Rune document syntax

A Rune file can be a structured data document on its own. Start with sections, add key-value pairs, and use records or series when you need more than one item.

Sections

Start a section with @ followed by its name. The lines below belong to that section until the next @ header. A slash in the header creates a nested path: @Guide/Author places Author inside Guide.

Rune

#!RUNE
# Sections group fields; / nests sections.
@Guide
title = Learning Vectrune

@Guide/Author
name = Mina

JSON output

{
  "Guide": {
    "Author": {
      "name": "Mina"
    },
    "title": "Learning Vectrune"
  }
}

#!RUNE is an optional file marker. The JSON beside each example is generated from that exact source by the Vectrune CLI.

Key-value pairs

A key-value pair (KV) gives a field a name and a value: key = value. Plain text can be written without quotes. Numbers and true or false become numeric and boolean values in the exported document.

Rune

@Settings
name = My first document
port = 3000
enabled = true

JSON output

{
  "Settings": {
    "enabled": true,
    "name": "My first document",
    "port": 3000.0
  }
}

Each pair belongs to the current section, or to the current record after a + marker. Use = for a value; use : for a series.

Records

Use + to begin a new record: a group of fields describing one item. Put the first field after +, then indent its remaining fields. Another + begins another record in the same section.

Rune

@Skateboarder
+ name = Mina
  style = Street
  active = true

+ name = Jules
  style = Vert
  active = false

JSON output

{
  "Skateboarder": {
    "record": [
      {
        "active": true,
        "name": "Mina",
        "style": "Street"
      },
      {
        "active": false,
        "name": "Jules",
        "style": "Vert"
      }
    ]
  }
}

Records export as a list under the section’s record key. A blank line makes them easier to read; the + marker starts the next item.

Series

A series is an ordered list. Write a name followed by a colon, then indent one item per line. The steps below become a list of strings, in the same order.

Rune

@Checklist
steps:
    Create a document
    Add a section
    Export to JSON

JSON output

{
  "Checklist": {
    "steps": [
      "Create a document",
      "Add a section",
      "Export to JSON"
    ]
  }
}

Indentation groups the items under steps:. In application sections, run: uses this same series shape for executable steps; these checklist items are just data.

Objects and inline lists

Use a JSON-style object when a field needs named subfields. For a compact list of simple values, use parentheses with spaces between items. Use a series when you want a longer, readable list.

Rune

@Settings
owner = { "name": "Mina", "role": "editor" }
features = (records exports)

JSON output

{
  "Settings": {
    "features": [
      "records",
      "exports"
    ],
    "owner": {
      "name": "Mina",
      "role": "editor"
    }
  }
}

The object’s field names and text values use double quotes. The parenthesized features list contains two separate string values.

A few rules to remember

  • Keep @ section headers at the start of the line. Use / to name nested sections.
  • A line beginning with # is a comment. Use full-line comments to explain your document.
  • Use consistent spaces to indent series items and the continuation fields of records.
  • Put section-wide values before the first +. Following key-value pairs belong to the current record until a new record or section begins.
Documents can stand on their own

You do not need @App, a server, or a run: block to describe data. Sections such as @Notebook and @Entry are your own names. Application sections such as @Route add runtime behavior when you build an app.

Try a document

Change the notebook title or a completion value, or add another + record. Press Run to see the new document. The editor will flag edits that have not been applied.

Choose JSON, YAML, or XML, then run or export the document. The AST button shows the parser’s internal structure.

Interactive

Read, edit, run

Apply the code to prepare this browser example, then send a request. Document and AST inspection are available under the advanced controls.

i18n.Sandbox.code

Inspect document or AST

Output

Apply code to prepare the example, then send a request.

This playground simulates requests in your browser. Apply the code, then choose an endpoint and press Send Request.

Use the same syntax locally

Save a document as notes.rune, then choose an output format with -o. The CLI also handles the series and inline-list examples above.

vectrune notes.rune -o json
vectrune notes.rune -o yaml
vectrune notes.rune -o xml
Explore the skateboarder document →
Built entirely with Rune-Web