svallin edited this page Jun 29, 2016 · 5 revisions


In some circumstances it is useful to be able to visualize YANG models as UML diagrams. Pyang supports two different ways of doing this:

  • Render png using PlantUML: pyang -f uml
  • Generate AppleScript that renders a OmniGraffle UML document OmniGraffle : pyang -f omni

Editable UML Graph in OmniGraffle

If you have OmniGraffle installed you can use this plugin to render a UML kind-of diagram in OmniGraffle. The good thing here is that you can modify the layout, remove parts of the diagram etc to make it more good looking.

Use this in the following way:

  1. Start OmniGraffle
  2. Generate the AppleScript file from the YANG module
  3. Run the AppleScript, this will open a OmniGraffle doc and render the UML diagram
$ pyang -f omni ietf-interfaces.yang -o ietf-interfaces.scpt
$ osascript ietf-interfaces.scpt

![] (

PlantUML output

The uml plugin to pyang generates a file that can be read by plantuml r7997 (

The following example converts the ietf-netconf-monitoring module into a UML diagram:

$ pyang -f uml ietf-netconf-monitoring.yang -o ietf-netconf-monitoring.uml
$ java -jar plantuml.jar ietf-netconf-monitoring.uml 
$ open img/ietf-netconf-monitoring.png

On some platforms Java might spit out "java.lang.OutOfMemoryError: Java heap space"

Pass the -Xmx<SIZE>m to java like:

$ java -Xmx1024m -jar plantuml.jar ietf-netconf-monitoring.uml 

Please note that the uml output has numerous options to tweak and simplify the layout. To skip details try the --uml-no= parameter. In many cases you like to inline augments and groupings, use the --uml-inline parameters.

You can also pass several YANG files to the UML output format, but the files must be given in dependency order. (Multi-file does not work for module/sub-module dependancies)

Another example with some parts suppressed:

$ pyang -f uml --uml-no=circles,stereotypes,annotation ietf-netconf-monitoring.yang -o ietf-netconf-monitoring.uml

A multi-file example from the ongoing YANG modeling in Metro Ethernet Forum

A complex example based on the Configuration Data Model for IPFIX and PSAMP

There is also a python script to generate a UML package structure for all yangs in a folder.


Use it in the following way:

$ ls *.yang | xargs -n1 pyang -f depend > packages.txt
$ uml-pkg --title=TITLE --inputfile=packages.txt > packages.uml
$ java -jar plantuml.jar packages.uml
$ open img/packages.png

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.