Skip to main content

Metamodel

A metamodel is the model of a model: it defines which elements, relationships and rules are allowed in a model. Metamodels play the same role for models as a grammar does for languages — they make models formally unambiguous and thus machine-processable, for example for validation and code generation.

What does a metamodel define?

A metamodel answers three questions about a modeling language:

  • Concepts: Which kinds of elements exist? (e.g., state, transition, event)
  • Relationships: How may elements be connected to each other, with which cardinalities? (e.g., a transition connects exactly one source state to exactly one target state)
  • Rules (constraints): Which additional conditions must a valid model satisfy? (e.g., every automaton has exactly one initial state)

Only this formal definition turns a model into more than a drawing: a tool can check whether a model is valid, and a generator can rely on which structures it will find.

A concrete example

A simple metamodel for state machines could look like this:

ConceptPropertiesRelationships
StateMachinenamecontains 1..* States, 0..* Transitions, 0..* Events
Statename, isInitial
Transitionguard (optional)exactly 1 source State, exactly 1 target State, 1 triggering Event
Eventname

Plus one rule: every StateMachine contains exactly one State with isInitial = true.

A concrete model — say, a traffic light controller with the states Red, Red-Yellow, Green, Yellow and transitions between them — is then an instance of this metamodel. The metamodel itself says nothing about traffic lights; it only says what a well-formed state machine is. Exactly the same relationship holds between a Java program and the Java grammar.

Meta levels: from object to MOF

The Object Management Group (OMG) organizes these relationships in a four-layer architecture:

  • M0 — the real runtime objects (the concrete traffic light at the intersection),
  • M1 — the model (the state machine of the traffic light controller),
  • M2 — the metamodel (the definition of what a state machine is; the UML metamodel also lives on this level),
  • M3 — the meta-metamodel: the Meta Object Facility (MOF), the language in which metamodels are described. The MOF describes itself; no further levels are needed.

In tooling practice, Ecore from the Eclipse Modeling Framework (EMF) frequently takes on the role of the M3 level — a pragmatic de facto standard that many modeling tools align with.

Metamodels in practice

Explicit metamodels are the foundation of every serious modeling toolchain. Whoever designs a domain-specific language (DSL) first designs its metamodel — from it, language workbenches such as Xtext or JetBrains MPS derive editors, live validation and the typed model API for generators. Metamodels are also the key when integrating heterogeneous tools: only when both sides formally expose their concepts can models be transformed and reconciled without loss. Practical experience shows: the hard part is rarely the technology, but the clean carving out of the domain concepts — a metamodel is always also a clarification of terminology within the team.

Frequently asked questions

What is the difference between a model and a metamodel?
A model describes a concrete system — for example the state machine of a traffic light controller. The metamodel describes which concepts are allowed to appear in such models in the first place — for example that there are states and transitions and that every transition has exactly one source and target state. Every model is an instance of its metamodel.
What is the MOF?
The Meta Object Facility (MOF) is the Object Management Group (OMG) standard for the topmost meta level: the language in which metamodels themselves are described. The UML metamodel, for example, is defined in MOF. In tooling practice, Ecore from the Eclipse Modeling Framework (EMF) frequently takes on this role.
Does every DSL need a metamodel?
Yes, at least implicitly. Every domain-specific language defines which concepts, relationships and rules can be expressed — exactly that is its metamodel. Language workbenches such as Xtext or JetBrains MPS make this metamodel explicit and derive the editor, validation and generator access from it.

Related terms

Reviewed by Axel Terfloth, Principal Engineer on July 20, 2026