AI-Ready Data Modeling Language
The Open Standard for AI-Ready Data Modeling
AIR-DML is a data modeling language designed for AI-driven development. It provides a structured, human- and machine-readable syntax for database schemas enriched with business context.
Mode-ai - AI-Powered Data Modeling Tool
Generate ER diagrams from natural language using AI. Mode-ai is the reference implementation of AIR-DML, showcasing the full potential of AI-ready data modeling.
- Natural language to ER diagram generation
- Interactive visual editor with drag & drop
- Export to SQL, AIR-DML, and more
✨ AI-Optimized: Designed for AI language models to understand and generate database schemas
🏗️ Domain-Driven Design: Built-in support for bounded contexts via Area
🌍 Multilingual: Logical names (aliases) in any language
🎨 Visual Design: Coordinate and color information for diagram rendering
🔄 Polyglot Persistence: Different database types per area
📦 Zero Dependencies: Independent parser with no external dependencies
💬 Comment Preservation: Leading comments are preserved and associated with elements
npm install air-dmlESM only. This package is published as an ES module (
"type": "module") and requires Node.js 18 or later. Useimport;require()is not supported. If you need it from CommonJS, use a dynamicawait import('air-dml').
import { parseAirDML, exportToAirDML } from 'air-dml';
// Parse AIR-DML text
const airDmlText = `
Project "My Project" {
database_type: "PostgreSQL"
}
// ユーザー管理
Table users [alias: "ユーザー", pos_x: 100, pos_y: 100, color: "#1976D2"] {
id serial [pk, alias: "ユーザーID"]
username varchar(100) [not null, unique, alias: "ユーザー名"]
email varchar(255) [not null, unique, alias: "メールアドレス"]
created_at timestamp [not null, alias: "作成日時"]
}
// プロフィール情報
Table profiles [alias: "プロフィール", pos_x: 500, pos_y: 100] {
id serial [pk, alias: "プロフィールID"]
user_id integer [fk, not null, unique, alias: "ユーザーID"]
full_name varchar(200) [alias: "氏名"]
bio text [alias: "自己紹介"]
}
Ref: profiles.user_id - users.id
Area "User Management" [
pos_x: 50,
pos_y: 50,
width: 600,
height: 300,
color: "#1976D2"
] {
users
profiles
database_type: "PostgreSQL"
CommonColumns: [
created_at timestamp [not null, alias: "作成日時"]
updated_at timestamp [not null, alias: "更新日時"]
]
Note: "ユーザー管理領域"
}
`;
const diagram = parseAirDML(airDmlText);
console.log(diagram);
// Export back to AIR-DML
const output = exportToAirDML(diagram);
console.log(output);Table table_name [alias: "論理名", pos_x: 100, pos_y: 200, color: "#1976D2"] {
column_name data_type [constraints, alias: "カラム論理名"]
Note: "テーブルの説明"
}
| Constraint | Description | Example |
|---|---|---|
pk |
Primary Key | id serial [pk] |
fk |
Foreign Key (use with Ref) | user_id integer [fk] |
unique |
Unique constraint | email varchar [unique] |
not null |
NOT NULL constraint | name varchar [not null] |
increment |
Auto increment | id integer [pk, increment] |
hidden |
Hide column in canvas | MANDT varchar [hidden] |
alias: "name" |
Logical name | [alias: "ユーザーID"] |
note: "desc" |
Column description | [note: "説明"] |
values: "k=v/..." |
Enum / classification values | [values: "1=有効/2=無効"] |
default: "val" |
Default value | [default: "active"] |
Define allowed values for a column (status codes, flags, etc.):
status varchar(1) [
not null,
alias: "ステータス",
values: "1=有効/2=無効/3=削除済",
default: "1"
]
Format: "key=label/key2=label2/..." — key and label separated by =, entries separated by /.
Ref: table_a.column > table_b.column // Many-to-One (A → B)
Ref: table_a.column < table_b.column // One-to-Many (A ← B)
Ref: table_a.column - table_b.column // One-to-One
Ref: table_a.column >< table_b.column // Many-to-Many
Ref: table_a.column ~ table_b.column // AI-inferred (undetermined)
Area "Area Name" [
pos_x: 50,
pos_y: 50,
width: 600,
height: 300,
color: "#1976D2"
] {
table1
table2
database_type: "PostgreSQL"
CommonColumns: [
created_at timestamp [not null, alias: "作成日時"]
updated_at timestamp [not null, alias: "更新日時"]
]
Note: "Area description"
}
A Lineage block records how one table is built: the order of processes, joins, where each column comes from, the kind of transformation, and — above all — the intent (Note: / note:). Expressions (expr:) are optional.
Lineage mart_campaign_daily [alias: "Daily campaign results"] {
Process 0 {
1 -> 2 -> mart_campaign_daily // process order (omit when there is one process)
}
Process 1 imp [alias: "Impressions per day and campaign"] {
served_date <- dwh_impression_fact.served_date [pk]
campaign_id <- dwh_impression_fact.campaign_id [pk]
impressions <- dwh_impression_fact [aggregate, note: "count rows"]
Note: "Bundle each impression into day x campaign"
}
Process 2 [alias: "Finish"] {
Join imp, dwh_campaign [inner, note: "keep campaigns present in both"] {
imp.campaign_id = dwh_campaign.campaign_id
}
served_date <- imp.served_date
campaign_id <- imp.campaign_id
campaign_name <- dwh_campaign.campaign_name
impressions <- imp.impressions
Note: "Add campaign names"
}
}
- Join kinds:
inner,left,right,full,cross. Transformations:aggregate,cast,calc,function,case,coalesce,constant. - Reading
Process 0: it is not a process but an index of how processes connect. In the example above,1 -> 2reads "process 2 uses the result of process 1", and2 -> mart_campaign_dailymarks process 2 as the last one, whose result is the built table (exactly one such arrow). Process numbers are labels; the arrows, not the numbers, decide the order. A process name (Process 1 imp) lets other processes use its columns asimp.column. - Join order: joins in a process are applied in the order written. The left name of the first
Join A, Bis the starting table (FROM); eachJoin A, BjoinsBto the result so far, whereAis a name that has already appeared andBis a name not yet used in the process. Read the kind as<result so far> <kind> JOIN B:leftkeeps every row of the result so far,rightkeeps every row ofB.lintLineagesdoes not check this order. - No new reserved words:
Lineage,ProcessandJoincan still be used as table or column names. <-,->and=are valid only insideLineage. Parsers older than 2.3.0 cannot read a document that containsLineage.- See
SPECIFICATION.mdsection 2.6 for the full syntax.
When using AI to generate AIR-DML, follow these rules:
Required:
- Use double quotes for alias values:
alias: "論理名"✅ - Do NOT use single quotes:
alias: '論理名'❌ - Mark foreign key columns with
[fk] - Define relationships separately with
Ref: - Do NOT add inline comments after column definitions
Example Output:
// 定期購入機能
Table subscriptions [alias: "定期購入"] {
id serial [pk, alias: "定期購入ID"]
user_id integer [fk, not null, alias: "ユーザーID"]
product_id integer [fk, not null, alias: "商品ID"]
status varchar(1) [not null, alias: "ステータス", values: "1=有効/2=停止/3=解約", default: "1"]
created_at timestamp [not null, alias: "作成日時"]
}
Ref: subscriptions.user_id > users.id
Ref: subscriptions.product_id > products.id
Use values: for any column with a fixed set of allowed values (status, type, flag, etc.).
Format: "key=label/key2=label2/..." with / separator.
For complete AI generation guidelines, see SPECIFICATION.md Section 5.
Parse AIR-DML text into a Diagram object.
Parameters:
airDmlText- AIR-DML formatted textdiagramId- Optional diagram ID
Returns: Diagram object
Parse AIR-DML text and return a ParseResult instead of throwing. This is the
recommended API for handling untrusted or user-supplied input, since parse
failures are returned as values rather than exceptions.
Parameters:
airDmlText- AIR-DML formatted textdiagramId- Optional diagram ID
Returns: ParseResult — { success, diagram?, error?, warnings? }
import { parseAirDMLSafe } from 'air-dml';
const result = parseAirDMLSafe(`
Table users {
id serial [pk]
}
`);
if (result.success) {
console.log(result.diagram.tables);
} else {
console.error(result.error);
}Use
parseAirDMLwhen a parse failure is a programming error and you want it to throw; useparseAirDMLSafewhen you want to inspect and report the failure.
v2.4.0+. Read several .aml files as one model. Files whose names have the
same prefix are combined into one Diagram; no syntax is added, so every
file is still a plain AIR-DML document. A large model can be split by business
domain, by kind of data, or with its Lineage blocks in separate files.
The prefix is the part of the file name (after the last / or \) before its
first .: sales.aml, sales.customers.aml and models/v1.0/sales.raw.aml
all have the prefix sales; pipeline.aml has pipeline. Prefixes are
compared as written (case-sensitive). Because files are chosen by name, they
are chosen before they are read.
Parameters:
files-{ name: string; text: string }[].nameis the file name (a path is fine); it is also shown in errors and warnings. The order of the array is the order of the files.options.project- the prefix to combine. Only the files with this prefix are read; files with another prefix are not read (a broken file there does not fail the call) and are reported with a warning. When omitted, every file must have the same prefix.options.diagramId- optional diagram ID
Returns: ParseResult — { success, diagram?, error?, warnings? }
import { parseAirDMLFiles, lintLineages } from 'air-dml';
const result = parseAirDMLFiles([
{ name: 'sales.customers.aml', text: customersText }, // Project "sales" + tables
{ name: 'sales.orders.aml', text: ordersText }, // Ref to a table in sales.customers.aml
{ name: 'sales.lineage.aml', text: lineageText }, // Lineage only (no Project needed)
]);
if (result.success && result.diagram) {
console.log(result.diagram.project); // 'sales'
console.log(result.diagram.tables.map((t) => t.name));
console.log(lintLineages(result.diagram)); // works on the combined diagram
} else {
console.error(result.error); // e.g. "sales.orders.aml: ..."
}How files are combined:
Projectmay be written in just one file; files withoutProjectare combined too. The diagram'sprojectis the name in the first file that writesProject, or the prefix when no file does. AProjectname that differs from the prefix gives a warning (the file is still combined).database_typeandNote: the earlier one is used, with a warning when they differ.- Tables keep the file order. The same table name in two files is an error.
RefandLineageare resolved after all tables are combined, so they may point to tables in other files. A file may hold onlyLineageblocks.Areablocks with the same name in different files become oneArea: tables andCommonColumnsare added in file order (the earlier column wins on the same name). When attributes differ, the earlier one is used with a warning.- Warnings, and errors for a chosen file that cannot be read, start with the file name (also when there is only one file). Errors for tables of the same name and for prefixes list the file names in the message.
Choosing which files to pass (for example, every .aml in a folder in name
order) is up to the application. See
SPECIFICATION.md 2.7 for the details.
Error classes thrown by parseAirDML and reported by parseAirDMLSafe.
Both extend Error, so they can be distinguished with instanceof.
LexerError- the input could not be tokenized (invalid character, unterminated string, ...)ParseError- the tokens could not be assembled into a valid document
import { parseAirDML, ParseError, LexerError } from 'air-dml';
try {
parseAirDML(text);
} catch (e) {
if (e instanceof LexerError) console.error('Tokenization failed:', e.message);
else if (e instanceof ParseError) console.error('Syntax error:', e.message);
else throw e;
}Export a Diagram object to AIR-DML text.
Parameters:
diagram- Diagram object
Returns: AIR-DML formatted text (including Lineage blocks)
Check the Lineage blocks of a parsed diagram. Parsing accepts any well-formed Lineage; this function reports structural errors (cycles in Process 0, no single arrow into the built table, unknown process numbers, …) and warnings (missing intent notes, missing join kind, columns that differ from the built Table, …).
import { parseAirDMLSafe, lintLineages } from 'air-dml';
const result = parseAirDMLSafe(text);
if (result.success && result.diagram) {
for (const issue of lintLineages(result.diagram)) {
console.log(issue.severity, issue.code, issue.lineage, issue.process, issue.message);
}
}Returns: { code, severity: 'error' | 'warning', lineage, process?, column?, message }[] (empty when there is no problem)
Get the list of supported data types for a specific database.
Parameters:
database- Database name:"PostgreSQL"|"MySQL"|"SQLite"|"SQL Server"|"Oracle"|"BigQuery"|"Redshift"|"Snowflake"
Returns: Array of data type strings
import { getDataTypesForDatabase } from 'air-dml';
const types = getDataTypesForDatabase('PostgreSQL');
// ["integer", "bigint", "varchar", "text", "boolean", "timestamp", ...]interface Diagram {
id: string;
name: string;
project?: string;
database?: string;
tables: Table[];
references: Reference[];
areas?: Area[];
createdAt?: string;
updatedAt?: string;
note?: string;
}
interface Table {
id: string;
name: string;
logicalName?: string; // alias
columns: Column[];
color?: string;
pos?: Position;
areaIds?: string[];
note?: string;
leadingComments?: string[]; // v1.2.0+
}
interface Column {
name: string;
logicalName?: string; // alias
type: DataType;
typeParams?: string;
pk?: boolean;
fk?: boolean;
unique?: boolean;
notNull?: boolean;
increment?: boolean;
hidden?: boolean; // v2.1.8+
note?: string;
values?: string; // v2.1.9+ — "key=label/key2=label2/..."
defaultValue?: string; // v2.1.9+
leadingComments?: string[]; // v1.2.0+
}
interface Reference {
id: string;
fromTable: string;
fromColumn: string;
toTable: string;
toColumn: string;
type: RelationshipType;
swapEdge?: boolean;
leadingComments?: string[]; // v1.2.0+
}
interface Area {
id: string;
name: string;
tables: string[];
color?: string;
pos?: Position;
width?: number;
height?: number;
labelHorizontal?: 'left' | 'center' | 'right';
labelVertical?: 'top' | 'center' | 'bottom';
databaseType?: string;
commonColumns?: Column[];
note?: string;
leadingComments?: string[]; // v1.2.0+
}| Feature | Description |
|---|---|
| Logical names | alias attribute for human-readable names in any language |
| Classification values | values attribute for enums and status codes |
| Area management | Bounded context grouping with CommonColumns and per-area database type |
| Visual layout | Coordinates, colors, and sizes for diagram rendering |
| Multi-DB | Area-level database type (polyglot persistence) |
| Lineage | How a table is built: process order, joins, column sources, and the intent of each transformation |
| Multiple files | Split a large model into several files and read them as one model by the file name prefix |
| AI-optimized | LLM-friendly syntax designed for generation and interpretation |
| Zero dependencies | Independent recursive descent parser |
- Added
parseAirDMLFilesto read several files as one model, chosen by the file name prefix (sales.*.aml) Ref,AreaandLineagemay point to tables in other files; same-namedAreablocks are combined
- Added the
Lineageblock (how a table is built) to parsing andexportToAirDML - Added
lintLineagesto checkLineageblocks <-,->and=outsideLineagenow drop only that block with a warning (previously the whole parse failed)
- Added
values: "key=label/..."column attribute for enum/classification values - Added
default: "value"column attribute (redesigned with double-quote consistency) - SAP R/3 namespace support:
/NAMESPACE/FIELDNAMEidentifiers in lexer
- Added
hiddencolumn attribute to hide columns from canvas display
- Fixed: attribute keywords (
alias,note, etc.) now usable as column names
- Fixed: top-level keywords (
project,table,ref,area) now usable as column names
- Fixed: multi-word type names (e.g.
timestamp with time zone) correctly quoted in export
- Added SQL standard type names to PostgreSQL (character varying, time with time zone, etc.)
- Expanded data type lists for all 8 databases (PostgreSQL, MySQL, Oracle, SQL Server, SQLite, BigQuery, Redshift, Snowflake)
- Added Snowflake database type support
- Breaking: Removed
defaultcolumn constraint (re-added in v2.1.9 with double-quote consistency)
- Major: Replaced
@dbml/coredependency with custom hand-written recursive descent parser - Full AIR-DML syntax support without external dependencies
- Improved error messages in Japanese
- Added leading comment preservation for Tables, References, and Areas
- Added
leadingCommentsfield to type definitions
- Initial release
- Core AIR-DML parsing and export
- Support for alias, pos_x, pos_y, color attributes
- Area with CommonColumns and database_type
For the complete AIR-DML specification, see SPECIFICATION.md.
Apache-2.0 License - see LICENSE file for details.
- Created by: Data-mination Partners
- Technical collaboration: Claude Sonnet 4.6 (Anthropic)
- GitHub Repository
- npm Package
- AIR-DML Specification
- Mode-ai - Reference implementation (AI-Powered Data Modeling Tool)
AIR-DML™ (AI-Ready Data Modeling Language) is a trademark of Datamination Partners Co., Ltd. Trademark Application No. 2026-000274 (Japan)
AIR-DML™ — The Open Standard for AI-Ready Data Modeling.