diff --git a/DynamicModel.cc b/DynamicModel.cc
index 1bd65d7299c6002ea1574ca5f9cc2444d39f300a..29858216deb9bcd05ef598a0b3e80775ea367019 100644
--- a/DynamicModel.cc
+++ b/DynamicModel.cc
@@ -5446,6 +5446,89 @@ void
 DynamicModel::writeJsonOutput(ostream &output) const
 {
   writeJsonModelEquations(output, false);
+  output << ", ";
+  writeJsonXrefs(output);
+}
+
+void
+DynamicModel::writeJsonXrefs(ostream &output) const
+{
+  output << "\"xrefs\": {"
+         << "\"parameters\": [";
+  for (map<pair<int, int>, set<int> >::const_iterator it = xref_param.begin();
+       it != xref_param.end(); it++)
+    {
+      if (it != xref_param.begin())
+        output << ", ";
+      output << "{\"parameter\": \"" << symbol_table.getName(it->first.first) << "\""
+             << ", \"equations\": [";
+      for (set<int>::const_iterator it1 = it->second.begin();
+           it1 != it->second.end(); it1++)
+        {
+          if (it1 != it->second.begin())
+            output << ", ";
+          output << *it1 + 1;
+        }
+      output << "]}";
+    }
+  output << "]"
+         << ", \"endogenous\": [";
+  for (map<pair<int, int>, set<int> >::const_iterator it = xref_endo.begin();
+       it != xref_endo.end(); it++)
+    {
+      if (it != xref_endo.begin())
+        output << ", ";
+      output << "{\"endogenous\": \"" << symbol_table.getName(it->first.first) << "\""
+             << ", \"shift\": " << it->first.second
+             << ", \"equations\": [";
+      for (set<int>::const_iterator it1 = it->second.begin();
+           it1 != it->second.end(); it1++)
+        {
+          if (it1 != it->second.begin())
+            output << ", ";
+          output << *it1 + 1;
+        }
+      output << "]}";
+    }
+  output << "]"
+         << ", \"exogenous\": [";
+  for (map<pair<int, int>, set<int> >::const_iterator it = xref_exo.begin();
+       it != xref_exo.end(); it++)
+    {
+      if (it != xref_exo.begin())
+        output << ", ";
+      output << "{\"exogenous\": \"" << symbol_table.getName(it->first.first) << "\""
+             << ", \"shift\": " << it->first.second
+             << ", \"equations\": [";
+      for (set<int>::const_iterator it1 = it->second.begin();
+           it1 != it->second.end(); it1++)
+        {
+          if (it1 != it->second.begin())
+            output << ", ";
+          output << *it1 + 1;
+        }
+      output << "]}";
+    }
+  output << "]"
+         << ", \"exogenous_deterministic\": [";
+  for (map<pair<int, int>, set<int> >::const_iterator it = xref_exo_det.begin();
+       it != xref_exo_det.end(); it++)
+    {
+      if (it != xref_exo_det.begin())
+        output << ", ";
+      output << "{\"exogenous_det\": \"" << symbol_table.getName(it->first.first) << "\""
+             << ", \"shift\": " << it->first.second
+             << ", \"equations\": [";
+      for (set<int>::const_iterator it1 = it->second.begin();
+           it1 != it->second.end(); it1++)
+        {
+          if (it1 != it->second.begin())
+            output << ", ";
+          output << *it1 + 1;
+        }
+      output << "]}";
+    }
+  output << "]}" << endl;
 }
 
 void
diff --git a/DynamicModel.hh b/DynamicModel.hh
index 6001c017a4ba79c269c28551227f35eeb95820a2..c9c9da8a4fa7d5e64da3a67871332cff654a8729 100644
--- a/DynamicModel.hh
+++ b/DynamicModel.hh
@@ -245,6 +245,9 @@ public:
   //! Write JSON prams derivatives file
   void writeJsonParamsDerivativesFile(ostream &output, bool writeDetails) const;
 
+  //! Write cross reference output if the xref maps have been filed
+  void writeJsonXrefs(ostream &output) const;
+
   //! Return true if the hessian is equal to zero
   inline bool checkHessianZero() const;
 
diff --git a/DynareMain2.cc b/DynareMain2.cc
index 5a870a62e11a25e4a3c17219f443e798f5b797ce..55f8304e4d747495038c8a5c6422acc68e7275a3 100644
--- a/DynareMain2.cc
+++ b/DynareMain2.cc
@@ -50,7 +50,7 @@ main2(stringstream &in, string &basename, bool debug, bool clear_all, bool clear
     mod_file->writeJsonOutput(basename, json, json_output_mode, onlyjson);
 
   // Perform transformations on the model (creation of auxiliary vars and equations)
-  mod_file->transformPass(nostrict, compute_xrefs);
+  mod_file->transformPass(nostrict, compute_xrefs || json == transformpass);
   if (json == transformpass)
     mod_file->writeJsonOutput(basename, json, json_output_mode, onlyjson);