diff --git a/src/core/js/ext_bookmarks.js b/src/core/js/ext_bookmarks.js
index 025f3f3c1ca8a876b51adeab3a0d99ba8bc39dbc..676d25c5fc38e5fa58f96a0c1a25dd6a7115b612 100644
--- a/src/core/js/ext_bookmarks.js
+++ b/src/core/js/ext_bookmarks.js
@@ -599,6 +599,20 @@ var ext_bookmarks = function ($, logger, config) {
         }
     }
 
+    /**
+     * Return the SELECT query created from the contents of the query response field
+     */
+    const get_query_from_response = function () {
+        // Go through divs in response field and extract the query string.
+        const divs = $(".caosdb-query-response-heading").find("div");
+        for (const div of divs) {
+            if (div.innerText.startsWith("Query:") && !div.innerText.includes("Results:")) {
+                return get_select_id_query_string(
+                    div.innerText.slice(div.innerText.indexOf(" ") + 1));
+            }
+        }
+    }
+
     /**
      * Initialize this module.
      */
@@ -690,6 +704,7 @@ var ext_bookmarks = function ($, logger, config) {
         init_button: init_button,
         get_bookmark_data: get_bookmark_data,
         get_select_id_query_string: get_select_id_query_string,
+        get_query_from_response: get_query_from_response,
     }
 };