TLDR: Use the option
-imageformat svg to generate an ER diagram in SVG format
SchemaSpy generates HTML documentation from your database schema, including
Entity Relationship diagrams. I find visualization helpful as a database model
Out of the box it produces diagrams in png format, like this one in the Hasura
I prefer SVG, because it scales, is smaller, and it is all text.
Using SchemaSpy to see what the relations are like is not complicated, once you
have downloaded the dependencies and figured out the command line options. And
there are quite a lot of command line parameters. I had to download the
postgresql jdbc driver by hand, and specify the path with the
<schemaspy-path>$ java -jar target/schemaspy-6.1.1-SNAPSHOT.jar \ -t pgsql -host localhost -db postgres -o /tmp -u postgres -dp . -p postgres -imageformat svg
The -t option is mandatory. Probably works for anything that has a JDBC
Driver. I use a local database inside a docker container that is only open to my
machine, so I left the passwords and the port at the default settings the
docker-compose configuration came with.
If you forget an option, Schema Spy will tell you what was missing. I stuck the
above in a shell script inside my project, so I can easily generate it again. I
left the output as
/tmp, so when I reboot (rarely), I am forced to create a
fresh diagram. Next step: integrate it into the build script, so I get
a fresh diagram whenever I add database migration files in the
SchemaSpy uses graphviz to generate images, the .dot files it uses as input, and
the generated images can be found in
At first I had a one liner for this, and then while writing the post, I found
that SchemaSpy supports SVG natively. It is 'just' another output parameter:
For more details, see the Get Started page in the SchemaSpy documentation .
I hope you found this helpful. It took me a bit of searching to find SchemaSpy, and the svg option. I'd be interested to know better alternatives, if there are any.