diff --git a/src/json.hpp b/src/json.hpp
index 3c57c42f..7adcbb43 100644
--- a/src/json.hpp
+++ b/src/json.hpp
@@ -5658,10 +5658,13 @@ class basic_json
         // reset width to 0 for subsequent calls to this stream
         o.width(0);
         // fix locale problems
-        o.imbue(std::locale(std::locale(), new DecimalSeparator));
+        auto old_locale = o.imbue(std::locale(std::locale(), new DecimalSeparator));
 
         // do the actual serialization
         j.dump(o, pretty_print, static_cast<unsigned int>(indentation));
+
+        // reset locale
+        o.imbue(old_locale);
         return o;
     }
 
diff --git a/src/json.hpp.re2c b/src/json.hpp.re2c
index 63141e20..4b86afd6 100644
--- a/src/json.hpp.re2c
+++ b/src/json.hpp.re2c
@@ -5658,10 +5658,13 @@ class basic_json
         // reset width to 0 for subsequent calls to this stream
         o.width(0);
         // fix locale problems
-        o.imbue(std::locale(std::locale(), new DecimalSeparator));
+        auto old_locale = o.imbue(std::locale(std::locale(), new DecimalSeparator));
 
         // do the actual serialization
         j.dump(o, pretty_print, static_cast<unsigned int>(indentation));
+
+        // reset locale
+        o.imbue(old_locale);
         return o;
     }
 
diff --git a/test/src/unit.cpp b/test/src/unit.cpp
index af16f00d..1f5c6d9f 100644
--- a/test/src/unit.cpp
+++ b/test/src/unit.cpp
@@ -14079,9 +14079,15 @@ TEST_CASE("regression tests")
         CHECK(j1a.dump() == "23.42");
         CHECK(j1b.dump() == "23.42");
 
+        // check if locale is properly reset
         std::stringstream ss;
+        ss.imbue(std::locale(std::locale(), new CommaDecimalSeparator));
+        ss << 47.11;
+        CHECK(ss.str() == "47,11");
         ss << j1a;
-        CHECK(ss.str() == "23.42");
+        CHECK(ss.str() == "47,1123.42");
+        ss << 47.11;
+        CHECK(ss.str() == "47,1123.4247,11");
 
         CHECK(j2a.dump() == "23.42");
         //issue #230