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

Symmetric Matrix Generator Options

Dimension and Format
Align all matrix elements in nice columns.
Non-diagonal Elements
Diagonal Elements

Symmetric Matrix Generator Examples (click to try!)

Symmetric Integer Matrix
In this example, we generate a symmetric 9 by 9 matrix that has positive single-digit numbers as its elements, both on the main diagonal and off-diagonal.
1 7 1 2 2 8 7 1 1
7 5 9 8 5 6 0 9 2
1 9 1 4 1 3 4 8 9
2 8 4 2 2 2 4 4 6
2 5 1 2 3 7 4 8 9
8 6 3 2 7 6 2 0 0
7 0 4 4 4 2 7 2 4
1 9 8 4 8 0 2 0 8
1 2 9 6 9 0 4 8 1
Number of rows and columns.
Separate matrix elements with this character.
Separate matrix rows with this character.
Prettify Matrix
Starting value (inclusive).
Ending value (inclusive).
Random Integers
Starting value (inclusive).
Ending value (inclusive).
Random Integers
Fractional Diagonal
This example creates a symmetric matrix with decimal fractions on the diagonal and binary elements in the symmetric part of the matrix. It sets the decimal precision to two digits and uses the "prettify" option to align the matrix columns.
2.09    1    1    1    0
   1 2.03    0    1    1
   1    0 2.58    1    0
   1    1    1 2.28    0
   0    1    0    0 2.36
Number of rows and columns.
Separate matrix elements with this character.
Separate matrix rows with this character.
Prettify Matrix
Starting value (inclusive).
Ending value (inclusive).
Random Integers
Starting value (inclusive).
Ending value (inclusive).
Random Decimals
If you're generating decimals, what's their precision?
Circled Digits
In this example, we have activated the custom element mode. For diagonal elements, we use black circled numbers and for the non-diagonal elements, we use white circled numbers.
❼ ⓪ ④ ⑦ ① ⑤ ② ⑤ ① ④
⓪ ❻ ⑤ ② ⑥ ⑤ ⑤ ② ⑨ ②
④ ⑤ ⓿ ④ ② ⑨ ② ④ ④ ⓪
⑦ ② ④ ❻ ② ③ ⑥ ⑤ ⑥ ⑨
① ⑥ ② ② ❾ ④ ⑧ ⑧ ⑥ ②
⑤ ⑤ ⑨ ③ ④ ❽ ⑤ ⑤ ① ⑤
② ⑤ ② ⑥ ⑧ ⑤ ❷ ⓪ ② ②
⑤ ② ④ ⑤ ⑧ ⑤ ⓪ ❷ ④ ⑦
① ⑨ ④ ⑥ ⑥ ① ② ④ ❸ ⑨
④ ② ⓪ ⑨ ② ⑤ ② ⑦ ⑨ ⓿
Number of rows and columns.
Separate matrix elements with this character.
Separate matrix rows with this character.
Prettify Matrix
Custom Elements
Enter custom elements here.
Custom Elements
Enter custom elements here.
Alpha-beta Matrix
In this example, we generate an 8x8 matrix that uses the Greek letters. In the upper and lower parts of the matrix, we use the symbols α (alpha) and β (beta), and for the center part, we use the symbol λ (lambda).
λ α α α α β α α
α λ α α α β α β
α α λ β β β α β
α α β λ α β α α
α α β α λ β β β
β β β β β λ α α
α α α α β α λ β
α β β α β α β λ
Number of rows and columns.
Separate matrix elements with this character.
Separate matrix rows with this character.
Prettify Matrix
Custom Elements
Enter custom elements here.
Custom Elements
Enter custom elements here.
Star Matrix
In this example, we create a symmetric matrix that looks quite extraordinary. We use six different Unicode star emojis to fill the non-diagonal part of the matrix and make the diagonal invisible by using the space character.
  ✸ ✷ ✹ ✵ ✹ ✷ ✸ ✸ ✸
✸   ✲ ✹ ✺ ✸ ✺ ✹ ✲ ✷
✷ ✲   ✵ ✷ ✵ ✹ ✵ ✺ ✺
✹ ✹ ✵   ✲ ✺ ✺ ✵ ✷ ✷
✵ ✺ ✷ ✲   ✺ ✷ ✸ ✵ ✷
✹ ✸ ✵ ✺ ✺   ✷ ✵ ✲ ✲
✷ ✺ ✹ ✺ ✷ ✷   ✹ ✲ ✹
✸ ✹ ✵ ✵ ✸ ✵ ✹   ✷ ✲
✸ ✲ ✺ ✷ ✵ ✲ ✲ ✷   ✹
✸ ✷ ✺ ✷ ✷ ✲ ✹ ✲ ✹  
Number of rows and columns.
Separate matrix elements with this character.
Separate matrix rows with this character.
Prettify Matrix
Custom Elements
Enter custom elements here.
Custom Elements
Enter custom elements here.
Playing Cards Matrix
This example generates a matrix with 36 Unicode playing card characters as its elements. It places the joker card 🃏 on the main diagonal and fills all other elements with four playing card suits ♠ ♣ ♥ ♦.
🃏 ♠ ♥ ♥ ♣ ♠
♠ 🃏 ♥ ♠ ♣ ♣
♥ ♥ 🃏 ♠ ♣ ♣
♥ ♠ ♠ 🃏 ♦ ♠
♣ ♣ ♣ ♦ 🃏 ♥
♠ ♣ ♣ ♠ ♥ 🃏
Number of rows and columns.
Separate matrix elements with this character.
Separate matrix rows with this character.
Prettify Matrix
Custom Elements
Enter custom elements here.
Custom Elements
Enter custom elements here.
Unit Matrix
In this example, we have generated a fully-filled unit matrix, which is also a symmetric matrix. Both, the diagonal and off-diagonal elements are set to 1 and the entire matrix consists of just ones.
1 1 1 1 1 1
1 1 1 1 1 1
1 1 1 1 1 1
1 1 1 1 1 1
1 1 1 1 1 1
1 1 1 1 1 1
Number of rows and columns.
Separate matrix elements with this character.
Separate matrix rows with this character.
Prettify Matrix
Custom Elements
Enter custom elements here.
Custom Elements
Enter custom elements here.
Zero Matrix
This example creates a null matrix. As all elements in a null matrix are zeros, the matrix is symmetric.
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.
Separate matrix elements with this character.
Separate matrix rows with this character.
Prettify Matrix
Starting value (inclusive).
Ending value (inclusive).
Random Integers
Starting value (inclusive).
Ending value (inclusive).
Random Integers
Diagonal Only
In this example, we are using an empty space character for non-diagonal elements and random integers from 10 to 99 as diagonal elements. As a result, the output is a diagonal line of integers.
53                  
  79                
    49              
      40            
        60          
          53        
            66      
              45    
                27  
                  72
Number of rows and columns.
Separate matrix elements with this character.
Separate matrix rows with this character.
Prettify Matrix
Custom Elements
Enter custom elements here.
Starting value (inclusive).
Ending value (inclusive).
Random Integers

How Does This Symmetric Matrix Generator Work?

This symmetric matrix generator works entirely in your browser and is written in JavaScript. A symmetric matrix can only be square and has the property aij=aji, which means its elements with respect to the main diagonal are identical. In the code, such matrices are implemented using two-dimensional arrays. If a matrix has the size n×n, then the starting two-dimensional array that represents it looks like this matrix = [[],[],…,[]], where empty cells [] appear n (or size) times. To generate this array, the generator calls matrix.push([]) for a total of n times. To fill the inside arrays with elements it uses two for loops. Since the values in upper and lower matrix parts are duplicates, the outer loop runs from i = 0 to i = size - 1 and the inner loop runs from j = i to j = size - 1. It uses three complex math formulas to generate the matrix elements matrix[i][j]. For integer values, it calculates r()*(end-start)+start, for fractions it calls Math.floor(r()*(end-start+1))+start, and for custom elements it runs elemArr[Math.floor(r()*elemArr.length)], where r() is the Math.random() function. The array elemArr is created from the custom matrix elements option elements. The variables start and end are also specified in the options. If i == j, then the diagonal options are used, if i != j, then non-diagonal options are used. The lower part of the matrix is filled by copying elements from the positions matrix[i][j] to positions matrix[j][i]. To print the matrix double array, it turns it into a string by calling the join(elSeparator) function for the internal arrays (elSeparator is the symbol that separates the matrix elements) and join(rowSeparator) for the external array (rowSeparator is the symbol that separates the matrix rows).

Created by Browserling

This symmetric matrix generator was created by me and my team at Browserling. Behind the scenes, it's actually powered by our programmer 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.