NC HDF5
File conversion

Convert NC to HDF5

QUICK ANSWER
Is it possible to convert NC to HDF5?
Yes - NC converts to HDF5.

Run ncdump -k yourfile.nc to check the format. If it reports netCDF-4, the file is already valid HDF5 - rename it .hdf5 and open it as-is. For classic netCDF, run nccopy -k netCDF-4 input.nc output.nc.

Also to HDF5: MAT · MF4

On this page

Tested on macOS, Windows & Linux
Last verified Oct 2026

More free converters

HEIC, PNG, WEBP, MP3 and more - every tool here is free.

Open the toolbox

Why convert NC to HDF5?

Some scientific pipelines and tools accept HDF5 but lack a dedicated netCDF driver. Converting produces a plain HDF5 file that any HDF5-aware reader such as h5py or HDFView can open without needing the netCDF library.

How to convert NC to HDF5

nccopy FREE

Run nccopy -k netCDF-4 input.nc output.nc to convert a classic netCDF file to netCDF-4/HDF5 format; rename the output to .hdf5 if your downstream tool requires that extension.

Python (netCDF4 + h5py) OPEN-SOURCE

Install with pip install netCDF4 h5py, read the .nc file with netCDF4.Dataset(), then write each variable to an HDF5 file using h5py.File() and create_dataset().

About these formats

Quality & what to watch

  • netCDF-4 is built directly on HDF5 - if ncdump -k yourfile.nc reports netCDF-4, you can rename the file to .hdf5 and open it with h5py or HDFView without any conversion.
  • Classic netCDF files start with the bytes CDF (hex 43 44 46) and are not HDF5 - these require nccopy or a Python rewrite to convert.
  • The reverse is not true: plain HDF5 files are not valid netCDF, so renaming .hdf5 to .nc will not work without restructuring the internal layout to match netCDF conventions.

Frequently asked questions

How do I know if my NC file is already HDF5?
Run ncdump -k yourfile.nc; if it returns netCDF-4, the file is HDF5 internally. You can also check whether the first two bytes are 89 48 (the HDF5 signature).
Will h5py be able to read the converted file directly?
Yes - after conversion with nccopy, the file is a valid HDF5 container; variable names and data are intact, though the internal structure follows netCDF naming conventions.
Is metadata preserved during conversion?
Variable data and dimensions are preserved by nccopy. When using h5py directly, you must copy attributes manually, as h5py does not transfer netCDF metadata automatically.