diff --git a/src/plugins/markdown-report/mdr_params.ml b/src/plugins/markdown-report/mdr_params.ml
index aa1f44492edcbf6bf96b42274c482d762f36f279..b63ea6261a1ee48bd6a1d7032e58a6b43dba795e 100644
--- a/src/plugins/markdown-report/mdr_params.ml
+++ b/src/plugins/markdown-report/mdr_params.ml
@@ -20,6 +20,8 @@
 (*                                                                        *)
 (**************************************************************************)
 
+module Pervasives_string = String
+
 include Plugin.Register(
   struct
     let name = "Markdown report"
@@ -27,14 +29,6 @@ include Plugin.Register(
     let help = "generates a report in markdown format"
   end)
 
-module Output = String(
-  struct
-    let option_name = "-mdr-out"
-    let arg_name = "f"
-    let default = "report.md"
-    let help = "sets the name of the output file to <f>"
-  end)
-
 module Generate = String(
   struct
     let option_name = "-mdr-gen"
@@ -45,6 +39,26 @@ module Generate = String(
        none (default), md, draft and sarif"
   end)
 
+module Output : Parameter_sig.String =
+struct
+  include String(
+    struct
+      let option_name = "-mdr-out"
+      let arg_name = "f"
+      let default = "report"
+      let help = "sets the name of the output file to <f>.@ \
+                  If <f> has no extension, it is chosen automatically based on \
+                  the report kind"
+    end)
+  let get () =
+    let s = get () in
+    if Pervasives_string.contains (Filename.basename s) '.' then s
+    else
+      let kind = Generate.get () in
+      let ext = if kind = "sarif" then ".sarif" else ".md" in
+      s ^ ext
+end
+
 let () =
   Generate.set_possible_values [ "none"; "md"; "draft"; "sarif" ]