← Back to Guides
DiagramsERD Diagrams in Markdown
Published on 2026-02-22

ERD Diagrams in Markdown

How to create Entity-Relationship Diagrams (ERD) using plain text.

ERD (Entity-Relationship Diagram) is a tool that translates plain text descriptions of relational database schemas into graphical diagrams. It’s incredibly useful for documenting database schemas quickly and keeping them close to your code.

In MarkdownToPrettyPDF, you can create these diagrams using the erd language block.

Basic Syntax

Entities are defined just by stating their name. You can add attributes enclosed in curly braces {}, and you can define relationships with standard connector syntax.

syntax
[Person]
*name
height
weight
+birth_location_id

[Location]
*id
city
state
country

Person *--1 Location
ERDERD diagram

Advanced Syntax

You can use standard ER notation for cardinality:

  • 1 : exactly one
  • ? : zero or one
  • * : zero or more
  • + : one or more
syntax
[Customer]
*id
name
email

[Order]
*id
customer_id
order_date
total_amount

[OrderItem]
*id
order_id
product_id
quantity

[Product]
*id
name
price

Customer 1--* Order
Order 1--+ OrderItem
Product 1--* OrderItem
ERDERD diagram

Styling and Layout

The ERD tool automatically handles the layout, producing clean, structured diagrams representing your data model. Attributes marked with * are rendered as primary keys, while + denotes foreign keys.

Using the erd tool is an excellent way to maintain up-to-date and easily readable database schemas right within your documentation.