Format Atlas

Compare

NPZ vs HDF5: array bundles and partial reads

NPZ bundles named NPY arrays in ZIP. HDF5 organizes groups, datasets, and attributes hierarchically.

Which format should you choose?

Use NPZ to exchange arrays with NumPy; consider HDF5 for repeated partial reads or hierarchical organization.

Good fit for NPZ

Bundling multiple NumPy arrays in one ZIP archive · Passing named arrays between NumPy scientific-computing workflows

  • Storing several arrays in one file
  • Choosing uncompressed or compressed ZIP members as needed

Good fit for HDF5

Storing large scientific and technical data hierarchically · Keeping multidimensional arrays and related metadata in one container

  • Organizing complex data with groups, datasets, and attributes
  • Scientific workflows needing partial I/O or dataset-level compression

Basic information

FieldNPZHDF5
Extension.npz.h5, .hdf5
MIME typeapplication/zip
Common usesBundling multiple NumPy arrays in one ZIP archive · Passing named arrays between NumPy scientific-computing workflowsStoring large scientific and technical data hierarchically · Keeping multidimensional arrays and related metadata in one container
How to openOpen with NumPy `load` or an NPZ-capable tool, inspect the array names, and load what you need. Close the returned `NpzFile` when finished; check pickle settings for unfamiliar files that may contain object arrays.Use HDF5-capable visualization or analysis software or a library. Inspect the group hierarchy, dataset shapes and types, attributes, and filters. Consult the creator's documentation because applications may define their own HDF5 conventions.
Export or convertSave multiple arrays with `savez` or `savez_compressed`. Confirm whether entries are uncompressed or DEFLATE-compressed, and check array names, dtype, and shape with the receiving tool. Compare arrays and values after conversion.Before converting to CSV, Parquet, FITS, or another format, decide how to map hierarchy, array dimensions and types, attributes, units, and coordinates. Some structures or metadata may not fit the target; keep the original and compare values and metadata.

Choose by use case

Storing several arrays in one file

Bundling multiple NumPy arrays in one ZIP archive · Passing named arrays between NumPy scientific-computing workflows

NPZ

Choosing uncompressed or compressed ZIP members as needed

Bundling multiple NumPy arrays in one ZIP archive · Passing named arrays between NumPy scientific-computing workflows

NPZ

Organizing complex data with groups, datasets, and attributes

Storing large scientific and technical data hierarchically · Keeping multidimensional arrays and related metadata in one container

HDF5

Scientific workflows needing partial I/O or dataset-level compression

Storing large scientific and technical data hierarchically · Keeping multidimensional arrays and related metadata in one container

HDF5

Key point 1

NPZ selects named archive members, each representing an array.

More on the differences

Key point 2

HDF5 supports selections within a dataset.

More on the differences

More on the differences

NPZ loads members on demand; ordinary numpy.load does not directly read arbitrary slices inside compressed members. HDF5 is not always faster: benchmark actual selections and chunk shapes.

  • savez is uncompressed; savez_compressed uses DEFLATE. HDF5 compression is optional. For chunked datasets, even one requested element involves its whole chunk.
  • HDF5 attributes can record units, but their meaning needs agreement. Check names, dtype, shape, axis order, values, and required filters during migration. Do not enable pickle for untrusted NPZ object arrays.

Frequently asked questions

Does converting NPZ to HDF5 automatically preserve meaning?

No guarantee. Define array-to-group mappings and conventions for units and missing values, then verify converted values.

Learn more

Related uses and checks

Checks before handing off scientific arrays

References and specifications