diff --git a/examples/parameter_example.yml b/examples/parameter_example.yml
index edb0885d621975850a09e4298b8e035ebb45a3cd..278990c76552312f28127b206a491a8f13e66d15 100644
--- a/examples/parameter_example.yml
+++ b/examples/parameter_example.yml
@@ -25,6 +25,7 @@ Snapshots:
   basename:   output      # Common part of the name of output files
   time_first: 0.          # Time of the first output (in internal units)
   delta_time: 0.01        # Time difference between consecutive outputs (in internal units)
+  compression: 0          # (Optional) Set the level of compression of the HDF5 datasets [0-9]. 0 does no compression.
   UnitMass_in_cgs:     1  # (Optional) Unit system for the outputs (Grams)
   UnitLength_in_cgs:   1  # (Optional) Unit system for the outputs (Centimeters)
   UnitVelocity_in_cgs: 1  # (Optional) Unit system for the outputs (Centimeters per second)
diff --git a/src/engine.c b/src/engine.c
index fc8850d0cb1fb1648a313e90fa1273246d8c7711..a626e611bce4dbc929cb80d90499413e3f2bd69c 100644
--- a/src/engine.c
+++ b/src/engine.c
@@ -2918,6 +2918,8 @@ void engine_init(struct engine *e, struct space *s,
       parser_get_param_double(params, "Snapshots:delta_time");
   e->ti_nextSnapshot = 0;
   parser_get_param_string(params, "Snapshots:basename", e->snapshotBaseName);
+  e->snapshotCompression =
+      parser_get_opt_param_int(params, "Snapshots:compression", 0);
   e->snapshotUnits = malloc(sizeof(struct UnitSystem));
   units_init_default(e->snapshotUnits, params, "Snapshots", internal_units);
   e->dt_min = parser_get_param_double(params, "TimeIntegration:dt_min");
diff --git a/src/engine.h b/src/engine.h
index e0c0f6a92e98a3c9a59f7db6a8ae930442ea5cac..ddb847d70c021f0ab044b1d42f49745433ab0ae1 100644
--- a/src/engine.h
+++ b/src/engine.h
@@ -150,6 +150,7 @@ struct engine {
   double deltaTimeSnapshot;
   int ti_nextSnapshot;
   char snapshotBaseName[200];
+  int snapshotCompression;
   struct UnitSystem *snapshotUnits;
 
   /* Statistics information */
diff --git a/src/serial_io.c b/src/serial_io.c
index c981e5e31db1868e6cd2590c6bb36d51282f94c7..7ecf88c4488912a238ceaa4ee2d131c5619dce76 100644
--- a/src/serial_io.c
+++ b/src/serial_io.c
@@ -224,10 +224,12 @@ void prepareArray(hid_t grp, char* fileName, FILE* xmfFile,
   }
 
   /* Impose data compression */
-  h_err = H5Pset_deflate(h_prop, 4);
-  if (h_err < 0) {
-    error("Error while setting compression options for field '%s'.",
-          props.name);
+  if(e->snapshotCompression > 0) {
+    h_err = H5Pset_deflate(h_prop, e->snapshotCompression);
+    if (h_err < 0) {
+      error("Error while setting compression options for field '%s'.",
+	    props.name);
+    }
   }
 
   /* Create dataset */
diff --git a/src/single_io.c b/src/single_io.c
index 93faab6717fb8c136559511ada2c928f185f9f42..de14a264dfab6f66b0abecc466ff34416425ee3f 100644
--- a/src/single_io.c
+++ b/src/single_io.c
@@ -261,10 +261,12 @@ void writeArray(struct engine* e, hid_t grp, char* fileName, FILE* xmfFile,
   }
 
   /* Impose data compression */
-  h_err = H5Pset_deflate(h_prop, 4);
-  if (h_err < 0) {
-    error("Error while setting compression options for field '%s'.",
-          props.name);
+  if (e->snapshotCompression > 0) {
+    h_err = H5Pset_deflate(h_prop, e->snapshotCompression);
+    if (h_err < 0) {
+      error("Error while setting compression options for field '%s'.",
+            props.name);
+    }
   }
 
   /* Create dataset */