HDF5 and NetCDF often appear together because NetCDF-4 stores data in an HDF5 container. That does not make them the same format. HDF5 is a general hierarchical storage system; NetCDF adds a constrained scientific data model and conventions that make variables easier to exchange between domain tools.
The short answer
| HDF5 | NetCDF | |
|---|---|---|
| Primary goal | General hierarchical scientific storage | Portable array-oriented scientific data |
| Structure | Arbitrary groups and datasets | Dimensions, variables, coordinates, attributes |
| Common extensions | .h5, .hdf5, .he5 | .nc, .nc4, .cdf |
| Conventions | Application-specific | Often CF conventions for climate and geoscience |
| Main APIs | libhdf5, h5py | netCDF-C, netCDF4-python, xarray |
| Relationship | Storage layer used by NetCDF-4 | Higher-level model; NetCDF-4 uses HDF5 |
HDF5 is a flexible hierarchy
An HDF5 file resembles a filesystem. Groups can contain more groups, datasets, links, and attributes. Dataset names and layouts are application-defined. This flexibility works well for instruments, simulation checkpoints, microscopy, NeXus, and custom data products.
The tradeoff is semantics. A dataset shaped [12, 37, 721, 1440] does not inherently say which axis is time, pressure, latitude, or longitude. The producer must encode that meaning through attributes, dimension scales, or an external convention.
Use the HDF5 viewer when you need to inspect this hierarchy directly.
NetCDF provides a scientific data model
NetCDF organizes data around named dimensions, coordinate variables, data variables, and attributes. In climate and earth science, the CF conventions standardize metadata such as units, coordinate axes, missing values, and grid mappings.
That stronger model lets applications understand a variable such as temperature(time, level, lat, lon) without knowing the producing instrument. The NetCDF viewer presents those dimensions and variables directly.
Where NetCDF-4 fits
There are two important storage families:
- NetCDF-3 classic and 64-bit-offset files use the original NetCDF binary layout. They are not HDF5.
- NetCDF-4 files use HDF5 underneath and add NetCDF rules and metadata.
An HDF5 library can open a NetCDF-4 container, but it exposes raw groups, datasets, attributes, and internal metadata. A NetCDF-aware library reconstructs the intended dimensions and variables. Conversely, an arbitrary HDF5 file may use features or structures that do not fit the NetCDF model.
Which should you choose?
Choose NetCDF when interoperability matters: climate models, ocean data, reanalysis, and tools such as xarray, Panoply, CDO, NCO, or GIS software benefit from consistent dimensions and CF metadata.
Choose HDF5 when you need application-specific hierarchy, mixed collections of datasets, custom links, or a domain standard already built on HDF5.
For conversion, do not flatten a whole container blindly. Inspect it first, choose one numeric dataset or variable, then export the relevant slice with HDF5 to CSV, HDF5 to JSON, or NetCDF to CSV.
Frequently asked questions
Can I rename an HDF5 file to .nc?
No. The extension does not add the NetCDF data model or required metadata. NetCDF tools may reject a generic HDF5 file even though both use the same underlying library.
Can HDFView open NetCDF-4?
Usually yes, because the storage container is HDF5. It will show the low-level hierarchy rather than the cleaner NetCDF variable model offered by a NetCDF-aware viewer.
Is NetCDF-3 obsolete?
No. NetCDF-3 remains simple, portable, and widely supported. It lacks NetCDF-4 features such as HDF5 compression and groups, but it is still common in operational scientific workflows.

