State Machine Diagram Tutorial

A state diagram, sometimes known as a state machine diagram, is a type of behavioral diagram in the Unified Modeling Language (UML) that shows transitions between various objects. Using our collaborative UML diagram software, build your own state machine diagram with a free Lucidchart account today!

Do you want to create your own UML diagram? Try Lucidchart. It's fast, easy, and totally free.

What is a state diagram in UML?

A state machine is any device that stores the status of an object at a given time and can change status or cause other actions based on the input it receives. States refer to the different combinations of information that an object can hold, not how the object behaves. In order to understand the different states of an object, you might want to visualize all of the possible states and show how an object gets to each state, and you can do so with a UML state diagram.

Each state diagram typically begins with a dark circle that indicates the initial state and ends with a bordered circle that denotes the final state. However, despite having clear start and end points, state diagrams are not necessarily the best tool for capturing an overall progression of events. Rather, they illustrate specific kinds of behavior—in particular, shifts from one state to another.

State diagrams mainly depict states and transitions. States are represented with rectangles with rounded corners that are labeled with the name of the state. Transitions are marked with arrows that flow from one state to another, showing how the states change. Below, you can see both these elements at work in a basic diagram for student life. Our UML diagram tool can help you design any custom state machine diagram.

And with our diagram as code feature, it’s faster and easier than ever. You can create a custom mockup of a state machine diagram and add it to your Lucidchart document using Mermaid coding.

State Diagram - Undergraduate States

State diagram applications

Like most UML diagrams, state diagrams have several uses. The main applications are as follows:

Do you want to create your own UML diagram? Try Lucidchart. It's fast, easy, and totally free.

State diagram symbols and components

You can include many different shapes in a state diagram, particularly if you choose to combine it with another diagram. This list summarizes the most common shapes you may encounter.

Composite state

A state that has substates nested into it. See the university state diagram example below. “Enrollment” is the composite state in this example because it encompasses various substates in the enrollment process.

Choice pseudostate

A diamond symbol that indicates a dynamic condition with branched potential results.

State Diagram Symbols - Choice Pseudostate

Event

An instance that triggers a transition, labeled above the applicable transition arrow. In this case, “classes end” is the event that triggers the end of the “Being taught” state and the beginning of the “Final exams” state.

State Diagram Symbols - Event Shape

Exit point

The point at which an object escapes the composite state or state machine, denoted by a circle with an X through it. The exit point is typically used if the process is not completed but has to be escaped for some error or other issue.

First state

A marker for the first state in the process, shown by a dark circle with a transition arrow.

State Diagram Symbols - First State

Guard

A Boolean condition that allows or stops a transition, written above the transition arrow.

State

A rectangle with rounded corners that indicates the current nature of an object.

State Diagram Symbols - State Shape

Substate

A state contained within a composite state's region. In the university state machine diagram found below, “Open for enrollment” is a substate in the larger “Enrollment” composite state.

Terminator

A circle with a dot in it that indicates that a process is terminated.

Transition

An arrow running from one state to another that indicates a changing state.

State Diagram Symbols - Transition Shape

Transitional behavior

A behavior that results when a state transitions, written above the transition arrow.

Trigger

A type of message that actively moves an object from state to state, written above the transition arrow. In this example, “Issue with reservation” is the trigger that would send the person to the airport travel agency instead of the next step in the process.

State Diagram Symbols - Trigger Shape

State diagram examples

Calendar availability state diagram example

This state machine diagram example shows the process by which a person sets an appointment on their calendar. In the “Check date” composite state, the system checks the calendar for availability in a few different substates. If the time is not available on the calendar, the process will be escaped. If the calendar shows availability, however, the appointment will be added to the calendar.

State Diagram Examples - Calendar Availability Example

University state diagram example

This state diagram shows the process of enrollment and classes at a university. The composite state “Enrollment” is made up of various substates that will lead students through the enrollment process. Once the student has enrolled, they will proceed to “Being taught” and finally to “Final exams.”

State Diagram Examples - University Example

Airport check-in state diagram example

The following example simplifies the steps required to check in at an airport. For airlines, a state diagram can help to streamline processes and eliminate unnecessary steps.