About Syntax Diagrams
See your grammar come to life.
Syntax diagrams — also called railroad diagrams — are a visual representation of formal grammar rules. They make the structure of a grammar immediately obvious in a way that reading rules never quite does.
A picture worth a thousand rules.
A railroad diagram represents each grammar rule as a path through a network of nodes. Terminal nodes — literal tokens like keywords and punctuation — are shown as rectangles. Non-terminal nodes — references to other rules — are shown as rounded rectangles. Alternatives branch into parallel paths. Optional elements have bypass paths. Repetitions loop back on themselves.

The result is a diagram that can be read left to right, following the paths, to understand exactly what sequences of tokens are valid according to the grammar.
Multiple grammar formats, one tool.
ANTLR3
ANTLR3 is the previous major version of ANTLR, with a large existing grammar base. ANTLR3 grammars support combined lexer/parser rules, tree grammars, rewrite rules for AST construction, and syntactic predicates for disambiguation. DevDiagrams renders the structural parser rules while ignoring code generation directives.
Bison
GNU Bison is a general-purpose parser generator compatible with Yacc. Bison grammars define terminal and nonterminal symbols, operator precedence and associativity, and grammar rules with semantic actions. DevDiagrams renders the structural grammar rules while ignoring embedded C actions and code generation directives.
BNF
Backus-Naur Form is the classic notation for context-free grammars, originally developed by John Backus and Peter Naur. DevDiagrams supports standard BNF with non-terminals in angle brackets, the ::= assignment operator, alternatives separated by |, and quoted string terminals.
ABNF
Augmented Backus-Naur Form, defined in RFC 5234 with extensions in RFC 7405, is the notation used throughout IETF internet standards. ABNF adds repetition operators, numeric value notation, and case sensitivity controls to standard BNF.
EBNF
Extended Backus-Naur Form, defined in ISO 14977, extends BNF with repetition using curly braces, optional elements using square brackets, grouping using parentheses, and an exclusion operator. Used widely in programming language and compiler specifications.
WBNF
W3C Extended Backus-Naur Form is the notation used throughout W3C specifications including XML, XPath, XQuery, and CSS. It uses ::= for assignment, implicit concatenation by juxtaposition, suffix operators ?, *, +, regex-style character classes, and Unicode hex character values.
More than just diagrams.
Railroad diagrams for every rule
Each rule in your grammar gets its own railroad diagram. Click any non-terminal node to navigate directly to that rule's diagram. Terminal nodes that correspond to defined lexer rules are also clickable.
Interactive grammar map
The grammar map visualizes the relationships between all rules in your grammar. Rules with no incoming references are marked as entry points — the roots of your grammar. Use the map to understand structure at a glance and spot orphaned rules that can never be reached.
Generate documentation
Export a complete self-contained HTML reference document containing all rules, their railroad diagrams, descriptions extracted from comments, and cross-references showing which rules reference each other. Share it with your team or embed it in your project documentation.
Export diagrams
Export any diagram as SVG for crisp vector graphics at any size, or as PNG for embedding in documents and presentations. SVG output can also be copied directly to the clipboard.
Navigation history
Back and forward navigation buttons let you retrace your steps through the rules you have visited, just like browser history. Use the rule list search to quickly jump to any rule by name.
Render history
DevDiagrams remembers your previously submitted grammars so you can return to them without re-entering your input. History retention is 30 days for free accounts, 6 months for Educational, and 2 years for Professional.
Writing grammars that diagram well.
1
Keep rules focused
Rules with many alternatives produce wide diagrams. Consider breaking complex rules into smaller named sub-rules — the diagram becomes more readable and each sub-rule gets its own diagram.
2
Document your rules with comments
Place a comment immediately above a rule and it will appear as a description in the generated documentation. Multiple contiguous comment lines are combined into a single description. Each grammar format uses its own comment syntax — see the grammar reference pages linked from the format cards above for details.
3
Use the grammar map
The grammar map shows how your rules relate to each other. Rules with no incoming references are entry points — the roots of your grammar. Use the map to spot orphaned rules that can never be reached.
4
ABNF incremental alternation
In ABNF, a rule defined with = can have additional alternatives added later using =/ . DevDiagrams merges all incremental alternations into the base rule and displays them as a single combined diagram.
5
Generate documentation
Once your grammar is rendered, click Generate Docs to produce a complete HTML reference document with all rules, their diagrams, descriptions, and cross-references. Share it with your team or embed it in your project documentation.
Ready to diagram your grammar?
Start diagramming →