What is the H5 file format?
The .h5 file extension denotes an HDF5 (Hierarchical Data Format version 5) file, a binary scientific data container developed by the HDF Group and originally created at the National Center for Supercomputing Applications (NCSA) in 1998. HDF5 is a self-describing, hierarchical format designed to store enormous multi-dimensional datasets alongside rich metadata.
Internally, an .h5 file is organised as a tree of named groups (analogous to directories) and datasets (N-dimensional typed arrays). Every dataset records its own data type, dimensions, byte order, and compression settings. Datasets can optionally be compressed on a per-chunk basis using GZIP, SZIP, Blosc, or Zstandard, enabling efficient storage even for terabyte-scale data. Each file and object can carry named attributes for additional metadata.
Common uses include:
- large scientific datasets in geoscience, physics, bioinformatics, and aerospace (NASA, NOAA, ESA, and CERN all rely on HDF5),
- storing Keras and TensorFlow neural network weights and model architectures,
- providing the underlying storage layer for NetCDF-4 files.
All HDF5 files begin with the magic signature \x89HDF\r\n\x1a\n (8 bytes, typically at offset 0). The format supports both little-endian and big-endian byte ordering, declared per file in the superblock. HDF5 files are read with Python’s h5py library, MATLAB, the h5dump command-line utility from the official HDF5 toolset, and the HDFView GUI.
The .h5 and .hdf5 extensions are interchangeable - both identify valid HDF5 files and are treated identically by all HDF5-aware software.
Security & safety
RISK: LOWHDF5 is a passive binary data container with no executable code. Safe to open. Very large datasets can cause memory issues if loaded entirely into RAM - use h5py's lazy-loading (f['/dataset'][::]) to slice large arrays. Malformed HDF5 files could trigger library bugs in older versions of libhdf5; keep the library updated.
Format details
in a nutshell- Keras/TensorFlow neural network model - Keras saves trained model weights and architecture to .h5 using HDF5; this is the same format, not a different one.
- NetCDF-4 climate/oceanography data - NetCDF-4 files (.nc, .nc4) are HDF5 files with additional NetCDF conventions; sometimes mistakenly saved as .h5.
Programs that open H5 files
Technical details
deep spec| Container format | HDF5 hierarchical group/dataset/attribute container |
| Magic bytes | 89 48 44 46 0D 0A 1A 0A; ASCII \x89HDF\r\n\x1a\n; 8 bytes at offset 0 (may appear at 512/1024/2048 offsets) |
| Byte order | Little-endian or big-endian, declared per file in the superblock |
| Encoding | Binary |
| MIME type | application/x-hdf5 |
| Compression | Optional per-dataset filter pipeline: GZIP, SZIP, LZF, Blosc, Zstandard, or none |
| Checksum | Fletcher32 per chunk (optional, per-dataset); superblock checksum in v2/v3 |
| Superblock versions | 0-3; v2/v3 add compact layout and file-space management |
| Max dataset dimensions | 32 dimensions; up to 2^64 elements per dimension |
| Chunking | Datasets can be split into fixed-size chunks enabling per-chunk compression, random access, and dynamic extension |
| Typical file size | 100 KB - 100 GB+ (Keras/TensorFlow model weights typically 1-500 MB) |
| Self-describing | Each dataset stores its own type, dimensions, byte order, compression, and named attributes |
| Backward compatibility | Newer HDF5 library versions read all older HDF5 files |
| Platform | Linux, Windows, macOS, HPC clusters (any POSIX OS) |
| Released | 1998 (HDF5 1.0 release by NCSA) |
| Latest version | HDF5 1.14 (2023); file format spec version 1.1 (adds new B-tree type) |
| Open standard | Yes · royalty-free |
| Specification | support.hdfgroup.org |
H5 conversions
Community Q&A
asked by usersNo questions yet - be the first to ask about H5 files.