Model to Text

Generate source code from Class diagrams and Statemachine diagrams to any lanauage you want. Sample templates for C++ (GR-SAKURA) included.


Compatible with
Astah Professional and UML, Community 6.7 or later
Latest Version
1.3.4 (Jan. 7, 2016)
No technical support is provided.

How to Install

  1. Download the Plug-in file.
  2. After the download is complete, drag the downloaded .jar file to an open instance of Astah. A pop-up will appear asking you to confirm installation choose [Yes]. If the pop-up below opens, restart Astah.
    Astah Plugin Install
  3. Launch Astah. If you find the [m2t] under the [Tools], that means the installation has completed successfully!
    Showing m2t option
  4. After you installed this plug-in, the folders below are created automatically and the sample template or .astah files are saved in there.
    Windows: C:/Users/{username}/.astah/plugins/m2t/
    Mac: UserHome/.astah/plugins/m2t/
    m2t plugin directory


How to Use

  1. Go to [Tools] – [m2t] – [Settings] to change the settings.
    (If you’d like to see the sample code with pre-installed template files, click here.)
    Configuration of m2t plugin
1. Templates Create a set of configurations to generate the code. [Add] creates a new configuration and [Remove] will delete one.
2. Template Dir Specify the directory where template files are installed. To create plural sets of configurations, create a folder to hold them in the directory below.
– Windows: C:/Users/{username}/.astah/plugins/m2t/templates/
– Mac: UserHome/.astah/plugins/m2t/templates/
3. Destination Path Specify the directory where you want to source code files to be exported to.
4. Template Mapping ap the template files. There are three categories to set the template files to.


This sets how to export classes that do not have stereotypes. Specify file extension and template file. Code will be exported in {Class name}.{File Extension}.


General setting. Specify the file name and template file. The code will be exported with {File name}.


Output setting for classes with specific stereotypes. Specify the stereotype, file extension, and template file. Code will be exported in {Class name}.{File Extension}.

Ref. How to create template files


2. Open the file you want to generate the source code of, then go to [Tools] – [m2t] – [Generate].
choosing Generate menu

3.”Code Generation is complete” message appears when it completes successfully.
Code Generation is Complete


Try m2t plugin with sample files

  1. Open LED-Camp3Sample.asta in ~/.astah/plugins/m2t/
    This .asta file has a Class diagram and StateMachine diagram. Also the “Controller” class has a statemachine diagram nested to it.
    Sample UML Class Diagram
    Sample UML Class Diagram
  2. Go to [Tools] – [mt2] – [Generate].
  3. “Code Generation is Complete” dialog appears when it completes. The source code should be exported to the default destination which is the user directory.
Back to Plugin List

What are you looking for?