Zarr

On this page 7

Zarr is an open storage format for chunked, compressed N-dimensional arrays, in which each chunk of an array is stored as a separate object and the structure is described by small JSON metadata documents. Among data formats, it occupies the niche of large numerical arrays such as climate model output, satellite imagery and microscopy volumes, where it is often used as a cloud-native alternative to HDF5 and NetCDF.

Zarr was created in the Python scientific ecosystem and is now governed by a community specification with implementations in Python, C, Java, Rust, JavaScript and Julia. Its central design idea is that a key-value store, whether a local directory or an object storage bucket, is enough to hold a dataset that many readers and writers can access in parallel without a shared file handle.

How Zarr stores chunked arrays

Zarr splits every array into a regular grid of chunks, compresses each chunk independently and writes it under a key derived from the chunk’s grid coordinates. A reader that needs a small region fetches only the chunks that intersect it, which is what makes partial reads over a network efficient.

Arrays are organized into groups, which form a hierarchy similar to folders. Each array and group carries a metadata document describing shape, data type, chunk shape, fill value and codec pipeline, plus arbitrary user attributes such as units or coordinate names. The table below lists the main building blocks.

ComponentRoleTypical content
StoreHolds keys and byte valuesDirectory, ZIP file, object storage bucket
GroupOrganizes arrays hierarchicallyMetadata and child arrays or groups
Array metadataDescribes one arrayShape, data type, chunk grid, codecs
ChunkUnit of storage and input/outputCompressed block of array elements
AttributesUser-defined descriptive metadataUnits, coordinate labels, provenance
Core components of a Zarr store

Because each chunk is an independent object, multiple processes can write different chunks concurrently without locking, provided they do not write the same chunk at the same time. This property fits distributed frameworks such as Dask, which map computation tasks onto chunks.

Zarr format versions and key features

Two major versions of the specification are in use: Zarr version 2, the long-standing format with metadata in .zarray and .zgroup files, and Zarr version 3, which consolidates metadata in zarr.json documents and introduces an extensible codec and storage model. Many tools now read both, but compatibility should be confirmed for each library.

FeatureZarr version 2Zarr version 3
Metadata files.zarray, .zgroup, .zattrsSingle zarr.json per node
Compression modelOne compressor plus filtersOrdered codec pipeline
ShardingNot supportedSupported via sharding codec
Extension mechanismLimitedFormal extension points
Ecosystem maturityVery broadGrowing rapidly
Comparison of Zarr version 2 and version 3

Sharding is the most significant practical addition in version 3. It packs many small inner chunks into one larger storage object with an index, reducing object counts in cloud storage while keeping fine-grained read access. Common compression codecs include Blosc, Zstandard and gzip, often combined with filters such as byte shuffling that improve compression of numerical data.

Zarr is most often compared with HDF5 and NetCDF, which also store chunked, compressed N-dimensional arrays. The decisive difference is that HDF5 and classic NetCDF-4 pack everything into a single file with internal structure, while Zarr spreads data across many independently addressable objects. Columnar formats such as Parquet solve a different problem: tabular records rather than dense arrays.

FormatData modelStorage layoutBest fit
ZarrN-dimensional arraysMany objects in a key-value storeCloud-based parallel array analysis
HDF5N-dimensional arrays and groupsSingle binary fileLocal or HPC file systems
NetCDFSelf-describing gridded variablesSingle file, often HDF5-basedClimate and ocean data exchange
ParquetColumnar tablesFiles with row groupsAnalytical queries on records
Cloud-optimized GeoTIFFTwo-dimensional raster imagesSingle tiled fileGeospatial imagery tiles
Zarr compared with neighboring formats

In practice, Zarr and NetCDF are frequently used together. The xarray library reads and writes both, and community conventions allow a Zarr store to carry the same dimension names and coordinate variables that NetCDF users expect, so that conversion between them preserves meaning.

Choosing chunk shapes and configuring a Zarr store

Performance with Zarr depends mainly on chunk shape and chunk size, which should match the dominant access pattern. A widely used guideline is chunks of roughly 1 to 100 megabytes uncompressed; the best value depends on storage latency, compression ratio and the number of parallel workers.

Access patternRecommended chunkingReason
Maps at one time stepFull spatial extent, one time stepOne chunk read per map
Long time series at a pointSmall spatial tiles, long time axisAvoids reading thousands of chunks
Mixed workloadsBalanced chunks or two copiesCompromise, or duplicate storage for speed
Very many tiny chunksEnable sharding in version 3Reduces object count and request overhead
Chunking decisions by access pattern

For cloud object storage, consolidated metadata, which collects all metadata into one document, avoids many small listing and read requests when a dataset is opened. Rechunking an existing dataset is expensive, so chunking should be designed before large-scale writes rather than corrected afterward.

Limitations and common mistakes

Zarr is not a database and offers no built-in transactions. Concurrent writes to the same chunk can corrupt or overwrite data, and object storage may expose partially updated datasets to readers during a write. Projects that need versioning or atomic commits add layers on top of Zarr rather than relying on the base format.

  • Chunks too small: millions of tiny objects cause slow listing and high request costs.
  • Chunks misaligned with access: time series reads across map-shaped chunks become very slow.
  • Version mismatch: a library that reads only version 2 cannot open a version 3 store.
  • Missing conventions: arrays without dimension names or units lose meaning when shared.
  • Using Zarr for tabular records: Parquet or Apache Arrow fits row-and-column data better.

In simple terms

Imagine a huge map of the whole planet for every day across many years. Storing it as one giant file makes it slow to open, especially over the internet. Zarr cuts that data into many small, labeled pieces and keeps a short description of how the pieces fit together.

When someone needs just one region or one week, the computer fetches only the matching pieces. Many computers can also work on different pieces at the same time. That is why Zarr suits very large scientific data stored in the cloud.

A practical example

A climate research group runs a regional model that produces hourly temperature, precipitation and wind fields on a 1-kilometer grid for 30 years. Stored as NetCDF files, the output exceeds 200 terabytes and analysts must download whole files to study one valley.

The group converts the output to a Zarr store in cloud object storage using xarray and Dask. Because most analyses examine long time series at limited locations, the team chooses chunks of 100 by 100 grid cells and one full year of hours, with sharding to keep the object count manageable.

Analysts now open the dataset directly from a notebook and extract a 30-year precipitation record for one catchment in minutes instead of hours. The outcome is faster analysis without data duplication, with all researchers reading the same authoritative copy.