What is the MAT file format?
.mat is a binary data file used by MATLAB - MathWorks' technical computing environment - to store named workspace variables. Arrays, matrices, structs, cell arrays and strings are all packed into a single .mat file, letting analysts save an entire working session and reload it exactly as it was left.
The format has evolved through several generations. The dominant Level 5 container, introduced in 1996, begins with a 128-byte ASCII descriptive header - the first bytes read MATLAB 5.0 MAT-file - followed by a sequence of tagged data elements (miMATRIX records) that each carry a variable name, data class and dimensions alongside the raw array bytes. Format v7 added optional per-variable DEFLATE (zlib) compression while keeping this same structure. MAT-file v7.3, shipped with MATLAB R2006b (2006), quietly switches the container to HDF5 - which is why some .mat files open in generic HDF5 tools such as HDFView while older ones do not. The v7.3 format also removes Level 5's practical ~2 GB per-variable size limit.
Saving and loading .mat files in MATLAB uses the save and load commands; pass -v7.3 to save to select the HDF5 backend. GNU Octave reads and writes both Level 5 and v7.3 natively. In Python, scipy.io.loadmat handles Level 5, while h5py tackles v7.3. Data can also be exchanged with .csv files for simpler tabular results. The registered MIME type is application/x-matlab-data.
Security & safety
RISK: LOWA .mat data file is passive - it stores numbers and strings, not executable code, so opening one to read its variables is low-risk. Two caveats: (1) MATLAB function handles and objects can be serialized into a .mat, and loading them can, in narrow cases, invoke class code - treat .mat files from untrusted sources with the same caution as any data you'll run through scripts; (2) a v7.3 .mat is an HDF5 file, so use a maintained HDF5/MAT reader. There's no macro-style auto-execution as in Office documents.
Format details
in a nutshell- 3ds Max / game-engine material file - Some 3D and game tools use .mat for a material definition (shaders/textures), unrelated to MATLAB.
- Audiotool .mat session - The online Audiotool music studio saves projects with a .mat extension.
- Microsoft Access table shortcut - Legacy: a small pointer launching an Access table - the (incorrect) name recorded in this site's database.
Programs that open MAT files
Technical details
deep spec| Developer | MathWorks |
| Format type | Binary scientific data container (arrays and named variables); v7.3 uses HDF5 on disk |
| Format versions | Level 4 (legacy, pre-1996), Level 5 (MATLAB 5-7), v7.3 (HDF5-based, R2006b onward) |
| Level 5 file signature | ASCII text "MATLAB 5.0 MAT-file" in a 128-byte descriptive header starting at byte offset 0 |
| v7.3 file signature | HDF5 magic bytes 89 48 44 46 0D 0A 1A 0A at offset 0; HDF5 userblock opens with "MATLAB 7.3 MAT-file" |
| Byte order | Self-described: "MI" = big-endian, "IM" = little-endian, stored at bytes 126-127 of the Level 5 header; v7.3 (HDF5) records its own byte-order metadata |
| Supported data types | double, single, int8/16/32/64, uint8/16/32/64, complex arrays, char, logical, struct, cell array, function handle |
| Compression | Optional per-variable DEFLATE (zlib) in Level 5 v7; HDF5 gzip/deflate filter available in v7.3 |
| Per-variable size limit | Level 5: ~2 GB per variable; v7.3 (HDF5): no practical upper limit - supports arrays exceeding 2 GB |
| MIME type | application/x-matlab-data (application/matlab-mat and application/octet-stream also seen in practice) |
| Level 5 internal structure | 128-byte descriptive text header followed by a sequence of tagged miMATRIX data elements, each storing variable name, class, dimensions and raw array data |
| HDF5 tool compatibility | v7.3 files are valid HDF5 and open in HDFView, the HDF5 C library, h5py and other HDF5-aware tools without MATLAB |
| Python access | scipy.io.loadmat for Level 5/v7 files; h5py or the mat73 package for v7.3 files |
| MATLAB save command flags | -v6 or -v7 selects Level 5; -v7.3 selects the HDF5-backed format (e.g. save('data.mat','varname','-v7.3')) |
| Integrity checking | Level 5 has no whole-file checksum; v7.3 (HDF5) supports optional per-dataset HDF5 checksum filters |
| Released | MAT-file Level 5 format with MATLAB 5 (1996); v7.3 (HDF5-based) added in MATLAB 7.3 (2006) |
| Latest version | MAT-file v7.3 (HDF5-based, supports variables > 2 GB); Level 5 still used by v6/v7 |
| Open standard | Yes · royalty-free |
| Specification | www.mathworks.com |
MAT conversions
Community Q&A
asked by usersNo questions yet - be the first to ask about MAT files.