Thousands of tools! Check out Online Tools – I have now added thousands of tools.

I often have to generate identity matrices so I created this simple online utility that does it for me. It lets you generate unit matrices of any size you need. It works in the browser and is powered by alien technology from the future.

Identity Matrix Generator Options

Dimension and Format
Matrix Elements
Output Format
Align all matrix elements in nice columns.

Identity Matrix Generator Examples (click to try!)

5x5 Unit Matrix
In this example, we generate a 5 by 5 unit matrix with 1's on the main diagonal.
1 0 0 0 0
0 1 0 0 0
0 0 1 0 0
0 0 0 1 0
0 0 0 0 1
Number of rows and columns.
Zero element.
Diagonal element.
Separate matrix elements with this character.
Separate matrix rows with this character.
Prettify Matrix
Identity Matrix with α's
This example creates a 10x10 identity matrix that uses the Greek letter α as the identity symbol on the diagonal.
α 0 0 0 0 0 0 0 0 0
0 α 0 0 0 0 0 0 0 0
0 0 α 0 0 0 0 0 0 0
0 0 0 α 0 0 0 0 0 0
0 0 0 0 α 0 0 0 0 0
0 0 0 0 0 α 0 0 0 0
0 0 0 0 0 0 α 0 0 0
0 0 0 0 0 0 0 α 0 0
0 0 0 0 0 0 0 0 α 0
0 0 0 0 0 0 0 0 0 α
Number of rows and columns.
Zero element.
Diagonal element.
Separate matrix elements with this character.
Separate matrix rows with this character.
Prettify Matrix
Stylish Matrix
In this example, we use extraordinary symbols for zeros and ones. For zeros that surround the diagonal, we use Unicode's enclosed zero ⓪ and for the ones, we use the enclosed one ①.
①⓪⓪⓪⓪⓪⓪
⓪①⓪⓪⓪⓪⓪
⓪⓪①⓪⓪⓪⓪
⓪⓪⓪①⓪⓪⓪
⓪⓪⓪⓪①⓪⓪
⓪⓪⓪⓪⓪①⓪
⓪⓪⓪⓪⓪⓪①
Number of rows and columns.
Zero element.
Diagonal element.
Separate matrix elements with this character.
Separate matrix rows with this character.
Prettify Matrix
Prettified Unit Matrix
This example sets three digits 111 as the unit symbols and enables matrix beautification option to make all columns evenly aligned.
111   0   0   0   0   0
  0 111   0   0   0   0
  0   0 111   0   0   0
  0   0   0 111   0   0
  0   0   0   0 111   0
  0   0   0   0   0 111
Number of rows and columns.
Zero element.
Diagonal element.
Separate matrix elements with this character.
Separate matrix rows with this character.
Prettify Matrix
Just the Diagonal
This example sets the zero value to a space. This makes all zeros of the unit matrix invisible and we print just the diagonal.
1          
  1        
    1      
      1    
        1  
          1
Number of rows and columns.
Zero element.
Diagonal element.
Separate matrix elements with this character.
Separate matrix rows with this character.
Prettify Matrix
Just the Zeros
This example does the opposite of the previous example. Here, the ones on the main diagonal are hidden but the zeros are output.
  0 0 0 0 0
0   0 0 0 0
0 0   0 0 0
0 0 0   0 0
0 0 0 0   0
0 0 0 0 0  
Number of rows and columns.
Zero element.
Diagonal element.
Separate matrix elements with this character.
Separate matrix rows with this character.
Prettify Matrix

How Does This Identity Matrix Generator Work?

This unit matrix generator works entirely in your browser and is written in JavaScript. As the identity matrix is a sparse matrix with unit elements only on the diagonal, then it uses two nested loops, indexed by i and j to print it. If i is equal to j, then it prints the unit element, otherwise, it prints the zero element. The loop runs until i and j reach size (matrix dimension; specified in options). The unit element is 1 by default and the zero element is 0 by default but you can customize them to any other symbols. For example, you can use + and -, 𝟘 and 𝟙, or and . Additionally, there are two separators that you can change. The first is the element separator. It's the symbol that gets put between elements on every row. The second is the row separator that gets put after one row of elements get printed. If the unit element is more than 1 character in length, then you can also prettify columns so that they look neat.

Created by Browserling

This identity matrix generator was created by me and my team at Browserling. Behind the scenes, it's actually powered by our web developer tools that are used by millions of people every month. Browserling itself is an online cross-browser testing service powered by alien technology. Check it out!

Secret message: If you love my tools, then I love you, too! Use coupon code TOOLLING to get a discount at my company.