ER Diagram Designer

ER Diagram Designer

Build a relational schema with real keys and constraint-backed cardinalities.

Local page memory only. Download project JSON to keep the design; there is no autosave.

Open a design

Supported syntax, names and limits

PostgreSQL subset: CREATE TABLE; column NULL/NOT NULL, PRIMARY KEY, UNIQUE and REFERENCES; table PRIMARY KEY/UNIQUE/FOREIGN KEY; ALTER TABLE ADD CONSTRAINT FOREIGN KEY. Explicit target column lists are required. Line and nested block comments are accepted. DEFAULT, CHECK, indexes, schema-qualified names, arrays, MATCH/DEFERRABLE options and trailing syntax are rejected. No SQL is executed.

Types: SMALLINT, INTEGER, BIGINT, TEXT, BOOLEAN, DATE, TIMESTAMP (without time zone), UUID, VARCHAR(1–10000), NUMERIC(p,s) with 1≤p≤100 and 0≤s≤p. INT/INT2/INT4/INT8/BOOL/DECIMAL normalize to canonical types. Other types and options are unsupported.

Form/JSON names are exact, case-sensitive identifiers; SQL output always double-quotes them. DDL unquoted identifiers use ASCII letters/underscore then letters/digits/underscore/$, fold to lowercase and cannot be PostgreSQL18 reserved words. Double-quoted identifiers retain case and Unicode. Empty, control-character, invalid-Unicode or over-63-UTF-8-byte names are rejected, never truncated. Constraint names are globally unique and cannot equal a table name in this profile. Names also reject U+FFFE/U+FFFF, which are not allowed in XML 1.0 SVG.

Foreign keys require ordered columns matching a declared target PK/UNIQUE, equal column counts and identical normalized types. Primary keys imply NOT NULL. SET NULL requires nullable child columns. Composite nullable foreign keys use PostgreSQL default MATCH SIMPLE: any NULL can avoid a parent match. Cycles are retained, not removed.

JSON format: {"format":"local-er-v1","dialect":"postgresql-subset-v1","tables":[...]}. Each table has name, columns, primaryKey (null or {name,columns}), uniqueKeys and foreignKeys. Columns have name,type,nullable. A foreign key has name,columns,target,targetColumns,onDelete,onUpdate. Export the example for a complete template. Unknown fields, decoded duplicate JSON keys and invalid references fail.

Limits: 256KiB UTF-8 input and JSON/DDL export; 24 tables, 40 columns/table, 300 columns total, 80 PK/UNIQUE keys and 80 FKs; 30,000 SQL tokens and 32 nested comment levels. An invalid or cancelled import leaves the previous design in memory and disables its stale exports until refreshed.

Load the example or add a table.

Tables and columns

Forms are drafts until Apply. The diagram/export uses only applied edits. Refreshing restores the applied design view without applying pending drafts. Deleting referenced objects fails until their dependent constraints are removed.

No database execution or server upload. Imported syntax outside this documented subset is rejected, even when valid in a full PostgreSQL installation.

Comments & questions

ER Diagram Designer

Turn a small relational schema into an editable diagram. Add tables and typed columns, define primary and unique keys, and connect ordered foreign-key columns. The same validated model drives the diagram and the generated PostgreSQL DDL, including self references and cycles.

Key features

  • Table and column forms with reference-aware renaming and validation before applying an edit
  • Ordered composite primary, unique and foreign keys with strict target-key and type checks
  • Required or optional parent relationships and one-child settings backed by NOT NULL and UNIQUE constraints
  • A documented PostgreSQL DDL subset with quoted identifiers, comments and precise rejection of unsupported syntax
  • Reusable project JSON, two-phase CREATE/ALTER DDL and a downloadable SVG diagram

How to use

  1. Open the composite-key and circular-reference example, import supported DDL/JSON, or add a table.
  2. Select a table and apply column, primary-key and unique-key edits. Names are exact identifiers; generated SQL quotes them.
  3. Select ordered child and parent columns for each foreign key. Set its delete/update actions and apply the relation.
  4. Review cardinalities and cycle markers. Changing optionality or choosing one child applies real schema constraints.
  5. Export the applied design as SQL, project JSON or SVG. Save JSON before leaving this page.

Use cases

  • Review a tenant-and-customer composite key before adding order relationships
  • Explain nullable parent references and one-to-one constraints during a database design review
  • Exchange a small cyclic schema using CREATE TABLE followed by ALTER TABLE foreign keys
  • Turn supported DDL into a readable table-and-key diagram without connecting to a database

Frequently asked questions

How is this different from the SQL formatter or data lineage designer?

The formatter lays out SQL and summarizes query table references. Lineage follows explicitly declared field dependencies. This tool defines table columns, relational keys, constraint-backed cardinality and DDL that can be reopened as the same normalized schema.

Which SQL can I import?

Only the documented PostgreSQL subset: CREATE TABLE with supported column types, NULL/NOT NULL, primary/unique keys and explicit foreign-key target columns, plus ALTER TABLE ADD CONSTRAINT FOREIGN KEY. DEFAULT, CHECK, indexes, schemas, arrays, MATCH clauses, deferrable constraints and other statements are rejected instead of ignored.

Are composite foreign keys and circular references supported?

Yes. Column order and count are retained, target columns must exactly match an ordered declared primary or unique key, and types must be identical after normalization. This is stricter than every compatibility rule PostgreSQL permits. Generated SQL creates all tables and keys first, then adds foreign keys, so cycles and self references survive import/export.

What do the cardinalities mean?

Each child has one required parent only when all its foreign-key columns are NOT NULL; otherwise it has zero or one under default MATCH SIMPLE behavior. A unique key contained in the child foreign-key columns restricts each parent to at most one related child; otherwise many are possible. A foreign key never requires a parent to have a child.

Can I restore and edit the exported files?

Project JSON uses local-er-v1 and postgresql-subset-v1 with exact properties. Reimport preserves the normalized schema. Generated DDL preserves schema semantics, while comments, original formatting and omitted constraint names are not retained; deterministic names are assigned. SVG is an illustration, not an editable project format.

Does validation prove the SQL will run on my database?

No database is contacted or SQL executed. This is a bounded design profile with global constraint-name uniqueness and exact foreign-key types. Review compatibility, privileges, existing objects and data before using generated SQL. Limits are 256KiB input/export, 24 tables, 40 columns per table, 300 total columns, 80 primary/unique keys and 80 foreign keys.

Privacy

Schema text, column names and uploaded files stay in page memory. This tool does not upload them, execute SQL, contact a database or automatically save to browser storage or a URL. Downloads and clipboard writes happen only when requested. Native file reading cannot be physically stopped, but cancelled or superseded reads cannot apply their result.

Related Tools

SQL FormatterJSON FormatterXML FormatterWasm Module InspectorHreflang Matrix CheckerAST Query PlaygroundContainer Build GraphDependency Graph ExplorerSemver Range LabCron Schedule AuditorPatch Review WorkbenchSource Map ExplorerLocalization Catalog AuditorStructured Data ReviewerHTTP Archive AnalyzerWebhook Signature LabProtobuf Schema WorkbenchGraphQL Schema LabAvro Schema EvolutionLocal SQL WorkbenchSchema Form BuilderMesh Repair WorkbenchPipe Network LabRobot Arm Kinematics LabThermal Network LabBeam Response LabGear Train DesignerTolerance Stackup LabSensor Calibration FitPCB Stackup PlannerDigital Filter DesignerNetwork Reachability MapSun Shadow MapGPS Error SimulatorDigital Logic SimulatorAnalog Circuit LabMechanism Linkage LabAnalysis Mesh GeneratorOpenAPI Contract InspectorDatabase Migration PlannerDimensional Equation CheckerTruss Force LabBoolean Minimization LabControl Response LabQueueing Simulation LabGeofence Event SimulatorCoordinate Reference LabSurvey Traverse LabRaster Classification LabChoropleth Design LabMap Print ComposerRaster Reprojection LabElevation Contour MakerTerrain Viewshed LabWatershed DelineatorMap Tile PackagerText File Encoding WorkbenchFilesystem Portability AuditorSBOM License ExplorerFile Signature Auditornpm Lockfile Conflict ResolverSource Secret AuditorOffline Web Package BuilderCertificate Chain InspectorTorrent Metainfo InspectorChunked File PackagerEncrypted File VaultDuplicate File FinderArchive WorkbenchDesign Token ManagerSpacing Token DesignerResponsive Type SystemPackaging Dieline DesignerSVG Icon Sprite PackerFlex Layout PlaygroundCSS Grid PlaygroundRegex Equivalence LabMarkdown Repository AuditorLog Template MinerResponsive Layout AuditorEmail Template PreviewInternal Link GraphState Machine TesterPetri Net SimulatorGit History VisualizerCurl Request WorkbenchBinary Protocol DesignerHex File EditorBinary Patch WorkbenchFile Signature WorkbenchAPI Mock SandboxSchema Column MapperEvent Log SessionizerTime Series Gap AuditorStratified Data SplitterData Lineage DesignerDecision Tree LabData Anonymization WorkbenchData Expectation RunnerJSON Schema ValidatorBasket Pattern AnalyzerRobots Policy TesterSEO HTML AuditorAccessibility Structure AuditorSyndication Feed WorkbenchIndexNow Payload BuilderCrawl Log AnalyzerCSP Policy WorkbenchSearch Performance AnalyzerCSV Formula Risk AuditorCORS Response SimulatorCache Header LabCookie Policy InspectorWeb Vitals Trace LabSitemap Health AuditorBatch File RenamerFile Manifest VerifierFolder Space MapFolder Difference ReviewerRoute Order OptimizerGeoJSON Map EditorPolygon Overlay LabCartographic Label PlacerSpatial Table JoinGeoJSON Topology AuditorGPX Track AnalyzerTrack Privacy RedactorCSV Table JoinCSV Pivot WorkbenchScientific Data ProfilerTabular Cleaning WorkbenchRecord ReconciliationData Dictionary BuilderCanonical Graph AuditorRedirect Plan TesterHTTP response and ping reference testBrowser and System InformationJSON ↔ YAML ConverterXML ↔ JSON ConverterHTML FormatterJavaScript MinifierMock Data Generator.gitignore GeneratorLicense GeneratorUser-Agent ParserPassword Strength CheckerCode to ImageHTTP Status Code LookupMIME Type LookupJS & SQL String EscapeCSS Box Shadow GeneratorCSS Gradient GeneratorIndent ConverterNumber Base ConverterUnicode Escape ConverterUnicode InspectorJSON Structure DiffMarkdown Table GeneratorBase64 EncoderURL EncoderCron Expression GeneratorRegex TesterUUID GeneratorHash GeneratorTimestamp ConverterJWT DecoderHTML Entity ConverterMarkdown PreviewCSS MinifierMeta Tag GeneratorJSON ↔ CSVCase ConverterImage to Base64
Explore all Dev Tools tools →Image/Media →Text/Convert →Life/Fun →