RSyntaxTree is a graphical syntax tree generator for linguistic research.

Web App · Example Gallery · Documentation

Features

RSyntaxTree provides a rich set of features for creating publication-quality syntax trees:

Basic Syntax

Use bracket notation to define tree structures:

[S [NP the cat] [VP [V sleeps]]]

Text Decoration

Apply various text styles to node labels:

  • Bold: **text**
  • Italic: *text*
  • Subscript: _text_
  • Superscript: __text__
  • Overline/Underline/Strikethrough: =text=, -text-, ~text~

Per-Node Coloring

Apply custom colors to individual nodes using @color: syntax:

[S [@red:NP the cat] [@blue:VP sleeps]]

Supports named colors (red, blue, green, etc.) and hex colors (@#FF5733:).

Enclosures and Triangles

  • Brackets: [#NP text] → draws brackets around the node
  • Rectangle: [##NP text] → draws a rectangle around the node
  • Triangle: [^NP the quick fox] → draws a triangle connector

Combine with colors: [#@red:NP text], [^@blue:VP phrase]

Region Shade

Shade the whole subtree a node governs with a semi-transparent plane — useful for c-command/binding domains and cognitive grammar dominions. Prefix the node with %; the color reuses the @color: syntax (bare % is gray):

[TP [DP everyone] [%@lightblue:T' [T will] [VP praise it]]]

Path Drawing

Connect nodes with lines or arrows:

[S [NP+1 text] [VP [V+>1 connects]]]

Multiple Output Formats

Generate trees in PNG, SVG, PDF, JPG, GIF, or LSIF (JSON) format.

Web Interface

A working web interface is available at https://yohasebe.com/rsyntaxtree.

You can also run RSyntaxTree's web interface on your local machine using Docker Desktop. See RSyntaxTree Web UI.

Examples

See RSyntaxTree Example Gallery for examples covering:

  • Generative Grammar
  • Combinatory Categorial Grammar
  • Head-Driven Phrase Structure Grammar
  • Cognitive Grammar
  • Construction Grammar
  • Pragmatics
  • Phonology
  • and more

Input text

[S
  [NP |R|<>SyntaxTree]
  [VP
    [V generates]
    [NP
      [Adj #\+multilingual\
            \+beautiful]
      [NP syntax\
          trees]
    ]
  ]
]

Output (PNG or SVG)

System Fonts

RSyntaxTree resolves fonts by family name through fontconfig (measurement via Pango, rendering via librsvg), so the fonts must be installed on the system that generates the images. Recommended:

  • Debian/Ubuntu: apt install fonts-noto-core fonts-noto-cjk fonts-noto-color-emoji
  • Alpine: apk add font-noto font-noto-cjk font-noto-cjk-extra font-noto-emoji (the -extra package carries Noto Serif CJK)
  • macOS: install Noto Sans/Serif (and Noto Sans/Serif JP for CJK); otherwise the system falls back to available fonts

Any script supported by an installed font renders correctly — the family chains fall back from Noto Sans/Serif to the JP and CJK variants, so Japanese, Chinese (simplified and traditional) and Korean are covered by the Noto CJK package. As of v1.8.0 the gem no longer bundles font files (they were not used at runtime).

Installation

gem install rsyntaxtree

macOS Installation Notice

Important for macOS users: If you encounter build errors for native extensions (gobject-introspection, cairo-gobject, gio2), run the following commands before installing RSyntaxTree:

gem install gobject-introspection -- --with-ldflags="-Wl,-undefined,dynamic_lookup"
gem install cairo-gobject -- --with-ldflags="-Wl,-undefined,dynamic_lookup"
gem install gio2 -- --with-ldflags="-Wl,-undefined,dynamic_lookup"

Then install RSyntaxTree:

gem install rsyntaxtree

Alternatively, use the Docker image or the web interface.

Usage

Command Line

Usage:
       1) rsyntaxtree [options] "[S [NP text] [VP here]]"
       2) rsyntaxtree [options] "(S (NP text) (VP here))"  # Penn Treebank format
       3) rsyntaxtree [options] "/path/to/text/file"
       4) echo "[S [NP text] [VP here]]" | rsyntaxtree [options]

Options

Option Description Default
-o, --outdir Output directory ./
-f, --format Output format: png, gif, jpg, pdf, svg, lsif png
-l, --leafstyle Leaf style: auto, triangle, bar, nothing auto
-n, --fontstyle Font style: sans, serif, cjk, mono sans
-s, --fontsize Font size: 8-26 16
-c, --color Color mode: modern, traditional, off modern
-p, --polyline Polyline connectors: on, off off
-d, --direction Tree layout direction: ttb, ltr ttb
--tidy Layout scale: off, symmetric, low, medium, high off
--hspacing Horizontal spacing factor, all layout modes (0.5-3.0) 1.0
-m, --mirror Flip the tree horizontally (RTL convention): on, off off

Run rsyntaxtree -h for the full list of options.

Input Formats

  • Bracket notation: [S [NP text] [VP here]]
  • Penn Treebank format: (S (NP text) (VP here)) - automatically converted
  • Standard input: echo "[S [NP text]]" | rsyntaxtree

Configuration File

RSyntaxTree supports configuration files (.rsyntaxtreerc) in YAML format. Place the file in your home directory or current working directory.

# ~/.rsyntaxtreerc
format: svg
color: modern
fontsize: 18

CLI options override config file settings.

Documentation

For detailed documentation on syntax and markup:

How to Cite

DOI

If you use RSyntaxTree in your research, please cite it. You can use the "Cite this repository" button on GitHub (powered by CITATION.cff), or the following BibTeX entry (adjust version to the one you used):

@software{hasebe_rsyntaxtree,
  author  = {Hasebe, Yoichiro},
  title   = {RSyntaxTree: A graphical syntax tree image generator},
  url     = {https://yohasebe.com/rsyntaxtree},
  doi     = {10.5281/zenodo.21916150},
  version = {1.8.0},
  year    = {2026}
}

Author

Yoichiro Hasebe (yohasebe@gmail.com)

License

RSyntaxTree is distributed under the MIT License.