a rust lib to visualize tree-sitter syntax tree

Screenshot 1

Screenshot 2


  • git clone this project

  • install npm / node.js

build and run example

  • cd frontend, run npm i --save and npm run build

  • cd .., run cargo run --example cpp_example

  • visit


see examples/cpp_example.rs

extern crate tree_sitter_cpp;
extern crate tree_sitter_viewer;

async fn main() -> Result<(), rocket::Error> {

    // initial code to display
    let code = r#"void main() {

    // specify the parser's language and the initial code.
    let result = tree_sitter_viewer::run(tree_sitter_cpp::language(), code );


label / legend explanation

  • black/plain text: A tree node’s kind
  • with green background: A tree node’s field_name, if there is one
  • pink, italic: the actual content of a node, only a leaf node / terminal will show this.


View Github