Skip to content

PyRailroad : Railroad-Diagram Generator

Generate Some railroad diagrams and more

PyRailroad is a Python package to draw railroad (or syntax) diagrams. Based largely on railroad-diagrams and the partial parser, both by tbatkins

This package can be used as a stand-alone (command-line interface) generator or as a library. this generates railroad diagrams (like what JSON.org uses) using SVG.

Railroad diagrams, or syntax diagrams, are useful in representing grammar in the programming sense.

Getting started

Install it with pip: python3 -m pip install pyrailroad

After that, py-railroad --help will show you some help.

This tool cas be used standalone as a command line program (CLI) or as a library. The former will give you details about the syntax of the input files or code used to generate the various diagram elements.

A Gallery is also coming soon to see how all the elements interact together.