A Guide to UML State Machine Diagram

Read his article to learn more about the symbols, elements, states, and events used in the state machine diagram.


State machine diagrams are one of the behavioral diagrams in Unified Modeling Language. These diagrams are used to depict the behavior of an object in a particular state. The object could behave differently in other states, too. However, in state machine diagrams, the behavior of an object within one state is defined. So, in these diagrams, the state is an abstraction that binds an object to behave in a particular way you want.

State machine diagrams are of great importance for a lot of models. The banking systems, shopping malls, admin panels, and library management use such models. So, understand these diagrams for proper execution of the system.

In this guide, you will be able to understand a lot about state machine diagrams, like what they are and how they are made. So, keep reading for more valuable information!

In this article
  1. What is a State Machine Diagram?
  2. Basic Concepts of State Machine Diagrams
  3. State Machine Diagram Symbols and Notations
  4. When to Use a State Machine Diagram?
  5. How to Draw a State Machine Diagram?
  6. Conclusion

Part 1. What is a State Machine Diagram?

State machine diagrams also help you understand the object's nature when the state is changed in the model. That's what makes it different from a sequence diagram, where events of a single interaction across all the objects in the system are noted.

In a state machine diagram, the behavior of the single object and all the states, transitions, and events are considered.

A state is the most important part of the Diagram. It contains links and attributes and their impacts on the other objects in the Diagram. In those states, the objects execute an activity and wait for the results. The transition helps the Diagram to move from one state to the other. 

The initial and final states of the diagrams become quite obvious when they are denoted differently. A single dark circle denotes the initial state, whereas the final state is shown with two circles, one being the dark inside a hollow circle. 

Why Use State Machine Diagrams? 

A state machine diagram is useful for viewing the dynamic behavior of the model. It also helps you visualize the behavior of the software application. As long as the system runs, the activity of the one object in a particular state is noted. It tells us a lot about the nature of the object and whether it will fit in a particular state.  

State machine diagrams offer us a blueprint of a model and information about its internal as well as external events. The entire creation and execution process is clearly shown in this Diagram. So, it is important to have a state machine diagram to run a model with full efficiency. Although it could get a little tough to understand when it is done, you can manage many things quickly.

State machine is used when there is a need to point out the events causing the transition from one state to another. These diagrams have a bigger role in forward and reverse engineering as well.

Part 2. Basic Concepts of State Machine Diagrams

Understanding the basic elements in a state machine diagram could clear our doubts and help us understand the basic concepts of these diagrams. These elements include initial states, transitions, decisions, states, fork, join, self-transition, composite states, and final states.

These elements serve different purposes and collectively make a state machine diagram. The most important ones are the states. They can be single or composite states in any diagram. A single state or simple state is just a direct path from one state to the other, whereas a composite state could contain complex paths with many other states and activities in between.

Part 3. State Machine Diagram Symbols and Notations

There are a few of the state machine diagram elements with their symbols given below. Let's check them out.

Initial State:

The dark circle defines the initial state; that's where the model starts.

Initial state representation in state machine diagram


A decision or condition is represented by an upside-down cube, as shown in the figure. Decision is usually used to apply a certain condition before entering a state.

decision or condition representation in state machine diagram


Transition is usually denoted by a line having an arrowhead at one end. The state is changed through this transition in any model. 

transitions between states are shown by an arrowhead line


The state has the simplest of notations. A rectangular shape with its edges rounded is used to represent a state. 

Composite State:

It is a little complex shape, with the state's name in it with conditions.

State diagram composite diagram representation


Fork is denoted by a single solid line in state machine diagrams where two states are formed by just one state.

Fork representation in state machine diagram


When two states join in following up a single state, it is called a join.

join representation in state machine diagram

Final State:

It is a state where the model ends and is represented by a hollow circle having a small dark circle inside it.

how to represent the final state

Part 4. When to Use a State Machine Diagram?

State machine diagrams focus more on the objects and their roles for a particular task. The objects react differently, being in different states. So, the nature of the object is well-defined in these diagrams.

Drawing the state machine diagrams gives developers a graphical representation of the events and activities within the system for better understanding. After having these diagrams to optimize the model to good effects, they are in a better position.

State machine diagrams are usually used for complex systems where many activities happen within one state. These diagrams help reduce the complexity by defining every action in the system using the right elements and notations. 

Although simple models use these diagrams, they tend to be used for clarity and a better understanding of the high-level systems.

Part 5. How to Draw a State Machine Diagram?

There are three main steps you need to keep in mind while drawing a state machine diagram. Let’s take a look at these steps.

1: Identify the States and Transitions

A system can have multiple states and transitions. So, the identification of those states and transitions is important. As described earlier, a state has different conditions and situations where a system lies, and transitions are the paths connecting those states. Transition also tells us about the direction of the flow in your system. So, identify them both.

how to represent states and transitions

2: Draw Events and Actions

Events and actions are two different things. Events are the ones that happen in a state or move from one state to the other while executing. Meanwhile, actions are the ones that define the behavior of the system after the response to the event. So, get a good idea of both.

3: Organize the Elements in the Diagram

This is the last step. You need to organize the elements in the diagrams with proper symbols and notations. There are different notations for every element and state. So, drawing and writing them correctly matters a lot for better understanding/. Draw the right symbols for each element and write down the notes if needed.

Understanding of events and elements in state machine diagram

State Machine Diagram Examples

These are the three state machine diagram examples to help you understand the basics.

State Machine Diagram for ATM System

An ATM is a very credential-sensitive machine. If even a signal entry is invalid, you cannot withdraw your money from the machine. This state machine diagram shows its working principle. This diagram shows that when a person enters his card into the machine, the machine reads the information from the card. 

If your card is valid, you can enter a PIN. Otherwise, the card will be ejected. The system checks if the PIN is valid, and you will proceed to choose the transaction and perform it. Otherwise, the machine will eject the card.

state machine diagram for ATM system

State Machine Diagram for a Sales Order

Here is another example of a state machine diagram where a customer shops online. He places an order, and the condition is applied automatically. The system will ask for a deposit if you buy something expensive. However, if your order is for a lesser amount, it will be placed automatically. The system will now deliver the order with an invoice for you to receive.

State machine diagram for sales order

State Machine Diagram for Admin Portal Login

Admin portal login diagram is one of the simplest ones for better understanding the concepts of state machine diagram. In this UML state machine diagram, the admin sitting behind the computer will enter credentials for login. If the credentials are correct, you will have a successful login.

If your credentials are wrong, you will be asked to enter the right credentials. In case of too many wrong login attempts, you will be asked to wait or log out of the system.

State machine diagram for admin portal login


State machine diagrams are essential when you need to see the behavior of the system when an event occurs. These diagrams help you understand the objects' behavior in different states. One object can behave differently when it is in some other state.

Software engineers and developers need these diagrams for multiple purposes. They need it to understand a running model or to make changes in the system for greater efficiency. So, if you want to draw your own state machine diagrams, you need to properly understand the elements, objects, and tools to draw them. If you want ready-made templates to make your work easier, try Edrawmax and get things sorted.

So, this was the full guide on drawing state machine diagrams and how they are helpful in any model. Follow the instructions and work like a professional.

edrawmax logoEdrawMax Desktop
Simple alternative to Visio
210+ types of diagrams
10K+ free templates & 26k+ symbols
10+ AI diagram generators
10+ export formats
edrawmax logoEdrawMax Online
Edit diagrams anywhere, anytime
Personal cloud & Dropbox integration
Enterprise-level data security
Team management and collaboration
Edraw Team
Edraw Team Jul 04, 24
Share article: