ER Diagram Tool for SQL Databases
Luna Modeler is an ER diagram tool for relational databases. It generates an entity-relationship diagram (ERD) from your existing database in a few clicks, lets you design new database structures visually, and turns the diagram into SQL scripts for PostgreSQL, MySQL, MariaDB, SQL Server, Oracle and SQLite. It is a desktop application that runs offline on Windows, macOS and Linux.

What Is an ER Diagram Tool?
An ER diagram tool is software for creating entity-relationship diagrams: visual models of tables, their columns and the relationships between them. General drawing apps can draw boxes and lines, but a database-aware ER diagram tool understands data types, primary keys, foreign keys and cardinality. That is what lets it read a diagram straight out of a database, validate your design, and generate SQL from it.
Luna Modeler goes beyond drawing: it is a full data modeling tool, so the ER diagram stays connected to the real database schema throughout its life.
Key Features of the Luna Modeler ER Diagram Tool
- Reverse engineering: generate an ER diagram from an existing database automatically.
- Visual schema design: add tables, columns, keys, indexes, relationships, views, enums, functions, procedures and other database-specific objects.
- Logical and physical data models: start database-independent and convert to a specific target database later.
- SQL script generation: create the database from the diagram with one click.
- Synchronization scripts: compare the ER diagram with a live database and generate ALTER statements.
- Sub-diagrams, automatic layout and line modes: keep large ER diagrams readable with curved, straight or orthogonal lines.
- Interactive HTML reports, PDF and PNG export: share ER diagrams with people who do not use the tool.
- Git-friendly projects and CLI automation: version and automate your data models.

Supported Databases
Luna Modeler works as an ER diagram tool for these database systems:
How to Generate an ER Diagram from an Existing Database
Creating an ERD from an existing database by hand is slow and error-prone. With an ER diagram tool that supports reverse engineering, it takes a few minutes:
- Install Luna Modeler: Download the desktop application for Windows, macOS or Linux.
- Connect to your database: Create a new connection, enter the server details (SSH and SSL/TLS are supported) and choose the schemas to load.
- Let the tool build the ERD: Luna Modeler creates a new project and places your tables, views and other objects on the diagram. Relationships are drawn from foreign keys, so you can see at a glance how tables are connected.
- Arrange and annotate: Apply an automatic layout, split the model into sub-diagrams and add notes or descriptions.

Benefits of Automatic ERD Generation
- Time-saving: No manual drawing of tables and relationships, and no mistakes from retyping column names.
- Clarity: A visual map of the database helps developers, analysts and new team members understand the data model quickly.
- Consistency: The Project Update feature compares the ER diagram with the current database and brings it up to date, so your documentation never drifts from reality.
How to Create an ER Diagram from Scratch
When the database does not exist yet, design it visually first and generate the SQL later:
- Create a new project: Start Luna Modeler and select your target database, e.g. PostgreSQL. The project opens with an empty ER diagram.
- Place tables: Click Table on the main toolbar and then click the diagram area. Each table represents one entity in your design.
- Define columns: Add columns and set names, data types, default values and nullability.
- Set primary keys: Mark the primary key for each table.
- Create relationships: Click Relationship, then click the parent table and the child table. The foreign key column is added for you.
- Specify cardinality: Define one-to-one, one-to-many or many-to-many (in a logical model) relationships. Learn more about crow's foot notation.
- Review and refine: Check the diagram for completeness, color related tables, and add notes and descriptions to make the ER diagram easy to read.

Grid and snap-to-objects alignment keep the ER diagram tidy as it grows:

Generate SQL Scripts from Your ER Diagram
Luna Modeler automatically generates SQL code for the selected target database. With one click you can view, copy or save the CREATE script for the whole diagram, including comments and descriptions.

When the database already exists, the ER diagram tool compares your model with the live database and generates ALTER statements, so changes are applied without dropping data.

Need a specific output format? Write custom templates to generate anything from your ER diagram.
Export and Share ER Diagrams
Click Report on the main toolbar and choose one of the export options:
- Export diagram to PDF: for printing or attaching to specifications.
- Export diagram to PNG: for wikis, tickets and presentations.
- Generate HTML report: an interactive document with the ER diagram and full details of every table, ready to share with your team.

For more information visit the Interactive HTML reports & Database reporting page.
Why Choose Luna Modeler as Your ER Diagram Tool
- Offline and private: Projects are local files. Your schema is never uploaded to a cloud service: see how your data is handled.
- Cross-platform: The same ER diagram tool on Windows, macOS and Linux.
- Round-trip workflow: Reverse engineer, design, generate SQL and synchronize, all in one application.
- Fair pricing: A free 14-day trial, then a one-time license with no subscription.
Comparing options? See how Luna Modeler stacks up as a dbdiagram.io alternative, or browse all comparisons. Looking for a free option for small projects? Read about free ER diagram tools.
An ER diagram tool is software for creating entity-relationship diagrams: visual models of tables (entities), their columns (attributes) and the relationships between them. A database-aware ER diagram tool such as Luna Modeler also understands data types, primary and foreign keys, and can generate the diagram from an existing database or generate SQL from the diagram.
Yes. Luna Modeler connects to your database, loads the selected schemas and places all tables, views and other objects on an ER diagram automatically. Relationships are drawn from the foreign keys. You can later update the diagram when the database changes.
Luna Modeler supports PostgreSQL, MySQL, MariaDB, SQL Server, Oracle and SQLite, plus cloud services such as Supabase and Neon. You can also create a database-independent logical data model and convert it to a physical model later.
Luna Modeler comes with a free 14-day trial that needs no credit card and no account. After the trial, it is a one-time $99 USD license: no subscription. If you only need a small free diagram, Datensen also offers freeware tools.
Yes. Luna Modeler is a desktop application for Windows, macOS and Linux. Projects are stored as local files, so you can design and review ER diagrams without an internet connection and your schema never leaves your machine.
Yes. Luna Modeler generates CREATE scripts for the target database from your ER diagram and can also generate ALTER (synchronization) scripts that apply model changes to an existing database.
Yes. Click Report on the main toolbar and choose Export diagram to PDF, Export diagram to PNG, or Generate HTML report for interactive documentation you can share with your team.
Entities, attributes and relationships. Entities are the objects in the system, such as a customer or an order. Attributes describe each entity, such as a name or address. Relationships show how entities are connected, such as a customer placing an order.
In Luna Modeler you can create a logical data model with entities, attributes and relationships, or a physical data model for a target database with tables, columns and relationships.
Yes. Luna Modeler includes sample ER diagrams in the Projects section, and more examples are available on the ER diagram samples page.

Download Luna Modeler in .dmg format from the Downloads page, open the file and drag the Luna Modeler icon into the Applications folder. Luna Modeler then appears in the list of applications.
