Matrix Transpose Calculator

Matrix Transpose Calculator A → AT

Enter a matrix (one row per line, numbers separated by spaces or commas). The calculator flips it across its diagonal, turning rows into columns.

Examples:

This free matrix transpose calculator flips any matrix across its main diagonal in one click, turning every row into a column and every column into a row. Paste a matrix above, press Transpose Matrix, and you instantly get MT along with the dimension change — no sign-up, works on mobile, and it mirrors exactly what NumPy’s .T returns.

What is the transpose of a matrix?

The transpose of a matrix is a new matrix formed by reflecting the original across its main diagonal — the diagonal that runs from the top-left corner down to the bottom-right. In plain terms, the first row becomes the first column, the second row becomes the second column, and so on. If the original matrix is written as M, its transpose is written MT (read “M transpose”).

Formally, the entry in row j, column i of the transpose equals the entry in row i, column j of the original: T[j][i] = M[i][j]. That single index swap is the whole operation. Because rows and columns trade places, the shape changes too. If M is an m × n matrix — that is, m rows by n columns — then MT is an n × m matrix. A tall matrix becomes wide, a wide matrix becomes tall, and a square matrix keeps its size but rearranges its off-diagonal entries.

The transpose is one of the most fundamental operations in linear algebra. It costs nothing conceptually — no arithmetic, just relabeling positions — yet it appears everywhere, from the normal equations of least-squares regression to the way attention scores are computed inside a transformer. Understanding it well pays off far beyond a single homework problem.

The rule in one line

To transpose a matrix, write its rows as columns: the value at position (row i, column j) moves to position (row j, column i). An m × n matrix becomes an n × m matrix.

How to use the matrix transpose calculator

The tool is built to be fast and forgiving. You only need one matrix, entered as a block of numbers:

  1. Type your matrix into the Matrix M box, one row per line. Separate the numbers in each row with spaces or commas — both work, and you can mix them.
  2. Make sure every row has the same number of values. A matrix must be rectangular; a ragged block like 1 2 3 on one line and 4 5 on the next is not a valid matrix.
  3. Press Transpose Matrix. The transpose appears as a grid below, and the dimension change — for example 3 × 2 → 2 × 3 — is shown above it.
  4. Open Show the rule to see how the first row of your matrix became the first column of the result.

If your input is not a valid rectangular matrix — because a row has a different length, or a value is not a number — the calculator clears the result and shows a plain-language error so you can fix the input rather than guess what went wrong. Negative numbers, decimals, and fractions written as decimals are all accepted.

Step-by-step worked example

Let us transpose a small non-square matrix so the shape change is easy to see. Take the 2×3 matrix:

M = [[1, 2, 3], [4, 5, 6]]

M has 2 rows and 3 columns, so it is a 2 × 3 matrix, and its transpose will be 3 × 2. To build MT, we take each row of M and stand it up as a column:

  • Row 1 of M is [1, 2, 3]. It becomes column 1 of MT.
  • Row 2 of M is [4, 5, 6]. It becomes column 2 of MT.

Reading the new columns off row by row gives the transpose:

MT = [[1, 4], [2, 5], [3, 6]]

Check a single entry to confirm the index-swap rule. The value 6 sat at row 2, column 3 of M, that is position (2, 3). In the transpose it lands at row 3, column 2, position (3, 2) — exactly the swap T[j][i] = M[i][j] promises. Notice too that the diagonal entries, here just the leading 1, never move: they already sit on the line of reflection.

Key properties of the transpose

The transpose obeys a handful of clean algebraic rules that come up constantly in proofs and derivations. They are worth memorizing.

The transpose of a transpose is the original

Applying the operation twice undoes it: (AT)T = A. Reflecting across the diagonal and then reflecting again puts every entry back where it started. This makes the transpose an involution — its own inverse.

The transpose of a product reverses the order

One rule surprises almost everyone the first time: the transpose of a product is the product of the transposes, but in reversed order. That is, (AB)T = BTAT. The order flip is not optional — it is exactly what makes the inner dimensions line up again after both matrices have been transposed. The same reversal extends to longer products: (ABC)T = CTBTAT.

Sums and scalars pass straight through

Transpose distributes over addition, (A + B)T = AT + BT, and scalars come along untouched, (cA)T = c AT. Only products carry the order-reversal wrinkle.

Symmetric matrices are their own transpose

A matrix that equals its own transpose, A = AT, is called symmetric. Symmetry forces the matrix to be square and to be a mirror image across the diagonal: the entry at (i, j) always equals the entry at (j, i). Covariance matrices, correlation matrices, and the Gram matrix XTX are all symmetric, which is one reason the transpose shows up so often in statistics and machine learning. Their symmetry guarantees real eigenvalues, a property that many algorithms quietly depend on.

Matrix transpose in Python with NumPy

In practice you will almost never transpose a large matrix by hand. NumPy gives you three equivalent ways to do it, and this calculator returns the same result as all of them:

import numpy as np
M = np.array([[1, 2, 3], [4, 5, 6]])
print(M.T) # attribute shortcut
print(np.transpose(M)) # function form
print(M.transpose()) # method form
# all give: [[1 4] [2 5] [3 6]]

The .T attribute is the one you will see most often because it is the shortest to type. Under the hood NumPy usually returns a view rather than a copy — it simply reinterprets the same data with swapped strides — which makes transposing essentially free even for very large arrays. If you need an independent copy you can write M.T.copy(). For higher-dimensional arrays, np.transpose accepts an axes argument so you can control precisely which dimensions swap.

Common mistakes to avoid
Three errors trip up most learners. First, forgetting the order reversal — writing (AB)T = ATBT instead of the correct BTAT. Second, entering a ragged, non-rectangular block and expecting a result; every row must have the same length. Third, assuming .T makes a fresh copy in NumPy — it often returns a view, so modifying the transpose can change the original array. When in doubt, transpose twice and check you get back what you started with.

Where the transpose appears in machine learning

The transpose is not an academic curiosity — it is load-bearing in the math of modern machine learning. When you compute the gradient of a linear layer during backpropagation, the weight matrix shows up transposed: the forward pass multiplies by W, and the backward pass multiplies the incoming gradient by WT. That transpose is what routes error signals back to the right inputs, and every deep-learning framework applies it automatically inside backward().

In classical linear regression, the closed-form solution runs entirely through transposes. The normal equations are (XTX)β = XTy, so fitting a model means forming XTX — a small symmetric matrix — and XTy, then solving for the coefficients. The same XTX is the (unscaled) covariance structure of the features, tying regression directly to statistics.

Transposes are just as central to the attention mechanism at the heart of transformers. Attention scores are computed as Q KT — the query matrix multiplied by the transpose of the key matrix — which produces a compatibility score between every query and every key. Without that transpose the dimensions would not align and the dot-product similarities could not be formed. From the smallest linear layer to the largest language model, the humble index swap you just performed above is doing quiet, essential work.

Frequently asked questions

What does transposing a matrix actually do?

It reflects the matrix across its main diagonal, turning every row into a column and every column into a row. The entry at row i, column j moves to row j, column i, and an m × n matrix becomes an n × m matrix.

Does the size of the matrix change when I transpose it?

The dimensions swap. A 3 × 2 matrix becomes 2 × 3. Only a square matrix keeps the same overall dimensions, though its off-diagonal entries still move.

What is a symmetric matrix?

A symmetric matrix is one that equals its own transpose, A = AT. It must be square, and its entries mirror across the diagonal so that the value at (i, j) equals the value at (j, i). Covariance and Gram matrices are common examples.

Why is (AB)T equal to BTAT and not ATBT?

Because transposing swaps the roles of rows and columns, the order of the factors has to reverse for the inner dimensions to match up again. This reversal is a rule you can prove entry by entry, and it extends to any number of factors.

How do I transpose a matrix in Python?

Use NumPy. Given an array M, the transpose is M.T, or equivalently np.transpose(M) or M.transpose(). All three return the same result this calculator produces.

Related calculators

Explore the full linear algebra calculators hub, or jump to the matrix multiplication calculator and the matrix determinant calculator to keep building your toolkit.