CSV Tools

Convert MAT to CSV

How to convert MATLAB .mat files to CSV — free methods, no MATLAB license required

Files saved with -v7.3 are HDF5 under the hood — the HDF5 guide pairs with this one. For formats we convert instantly in the browser, see all of our CSV converters.

A .mat file is a saved MATLAB workspace: one or more named variables in a single binary file. One fact decides which tools work on yours: files saved with MATLAB’s -v7.3 flag are secretly HDF5 files and need different tooling than v7.2 and older — if a converter fails with an “unable to read” error, that’s almost always why (see the FAQ). There’s no in-browser converter for this format here yet, so this guide covers the free routes. Fastest with no software: Octave Online below. Python users can jump ahead.

No installation: convert in the browser

Option 1: Octave Online

Octave Online (octave-online.net) is a free browser version of GNU Octave, the MATLAB-compatible environment.

  1. Open it — Go to octave-online.net and sign in (free — required to upload files).
  2. Upload your file — Use the file panel on the left to upload your .mat file.
  3. Run the commands — Paste these into the prompt, one at a time:
load yourfile.mat            % replace with your uploaded filename
whos                         % lists the variables inside
csvwrite("output.csv", A)    % replace A with a variable name from whos
  1. Download the resultoutput.csv appears in the file panel; download it from there.

Two honest caveats: csvwrite handles numeric matrices only (for cell arrays or structs, use the Colab option), and Octave cannot load -v7.3 files — if load errors, use the Colab h5py snippet in the Python section below.

Option 2: Google Colab with scipy

  1. Open Colab — Go to colab.research.google.com, sign in with any Google account, and click New Notebook.
  2. Upload your file — Click the folder icon in the left sidebar, then the upload button, and select your .mat file.
  3. Run the code — Paste the snippet below into the cell and press the run button.
  4. Download the result — Refresh the file sidebar, right-click output.csv, and choose Download.
from scipy.io import loadmat
import pandas as pd

data = loadmat("yourfile.mat")  # replace with your uploaded filename
print([k for k in data if not k.startswith("__")])  # your variable names
df = pd.DataFrame(data["A"])  # replace A with one of the printed names
df.to_csv("output.csv", index=False)

Your uploaded file lives in a temporary private session that disappears when you close the tab — but it is on Google’s servers, so for confidential data use the desktop option below.

Free desktop app: GNU Octave

GNU Octave is a free MATLAB-compatible environment (Windows/macOS/Linux, from octave.org). Like the R case for .rds files, this is an app plus two pasted commands, not a tool you need to learn: install it, then run the same load / whos / csvwrite commands from the Octave Online section. Everything stays on your machine.

Python

scipy.io.loadmat() returns a dictionary of variable names to arrays (plus a few __header__-style keys you can ignore):

# pip install scipy pandas
from scipy.io import loadmat
import pandas as pd

data = loadmat("data.mat")
print([k for k in data if not k.startswith("__")])  # see the variable names
pd.DataFrame(data["A"]).to_csv("output.csv", index=False)  # replace A

For -v7.3 files, loadmat raises an error — read them as HDF5 with h5py instead (this is the same task as the HDF5 guide):

# pip install h5py pandas
import h5py
import pandas as pd

with h5py.File("data.mat", "r") as f:
    print(list(f.keys()))  # variable names
    data = f["A"][()]      # replace A with one of the printed names

pd.DataFrame(data).to_csv("output.csv", index=False)

One gotcha: MATLAB stores arrays column-major, so v7.3 arrays arrive transposed through h5py — if rows and columns look swapped, use data.T.

R

For v7.2 and older files only, R.matlab::readMat("data.mat") returns a list of the file’s variables — extract the one you want and write.csv() it. The package refuses -v7.3 files; use the h5py route for those.

Which method should I use?

Your situationBest method
No software installed, one file, data not confidentialOctave Online or Google Colab
Confidential data that can’t leave your computerGNU Octave
Many files, or a task you’ll repeatPython with scipy (h5py for v7.3)

FAQ

4 questions
Can I open a .mat file without MATLAB?
Yes. Octave Online opens .mat files in your browser with no install, GNU Octave does the same on your desktop, and Python's scipy.io.loadmat() reads them in a script or in Google Colab. None of these needs a MATLAB license.
Why do I get an 'unable to read MAT-file' or v7.3 error?
The file was saved with MATLAB's -v7.3 flag, which stores data as HDF5 rather than the classic MAT layout. scipy.io.loadmat(), Octave's load, and R.matlab all refuse it. Read it with h5py instead — h5py.File('file.mat', 'r') — and export the variable you need; the approach is the same as for any HDF5 file.
My .mat file has multiple variables — which one becomes the CSV?
You choose. A .mat file is a saved workspace, so each variable is a separate array. List the names first (whos in Octave, or the loadmat dictionary keys in Python), then export the variable you want — one CSV per variable.
Can Excel open .mat files?
No. Excel cannot read MATLAB's binary format. Convert the variable you need to CSV first using any method in this guide, then open the CSV in Excel.

More Format Guides & Converters

6 pages

More Convert File Formats Tools

23 tools