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 machine that generates the images. As of v1.8.0 the gem no longer bundles font files; they were not used at runtime.

  • Debian/Ubuntu: apt install fonts-noto-core fonts-noto-cjk
  • Alpine: apk add font-noto font-noto-cjk font-noto-cjk-extra (the -extra package carries Noto Serif CJK)
  • macOS: brew install --cask font-noto-sans font-noto-serif font-noto-sans-mono font-noto-sans-jp font-noto-serif-jp font-noto-sans-cjk font-noto-serif-cjk font-noto-sans-mono-cjk-jp (macOS itself ships Noto only for a few rare scripts)

Arabic, Hebrew, Devanagari, Thai and Khmer need their own packages, and emoji need the monochrome Noto Emoji — colour emoji fonts are not drawn by this pipeline:

  • Debian/Ubuntu: fonts-noto-core covers the scripts; on minimal images add fonts-noto for the full set
  • Alpine: apk add font-noto-arabic font-noto-naskh-arabic font-noto-hebrew font-noto-devanagari font-noto-thai font-noto-khmer
  • macOS: the same families are available as font-noto-* casks

See Fonts in the documentation for which family is used for what, how to substitute your own, and the macOS caveats.

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.