diff --git a/builtin/common/misc_helpers.lua b/builtin/common/misc_helpers.lua
index 48488ab62d47c0354ef49c5352c0d211b094d168..0b608126e52e4f4df332d26b3ecfb019285796d2 100644
--- a/builtin/common/misc_helpers.lua
+++ b/builtin/common/misc_helpers.lua
@@ -490,6 +490,18 @@ function core.pos_to_string(pos)
 	return "(" .. pos.x .. "," .. pos.y .. "," .. pos.z .. ")"
 end
 
+--------------------------------------------------------------------------------
+function table.copy(t, seen)
+	local n = {}
+	seen = seen or {}
+	seen[t] = n
+	for k, v in pairs(t) do
+		n[type(k) ~= "table" and k or seen[k] or table.copy(k, seen)] =
+			type(v) ~= "table" and v or seen[v] or table.copy(v, seen)
+	end
+	return n
+end
+
 --------------------------------------------------------------------------------
 -- mainmenu only functions
 --------------------------------------------------------------------------------
diff --git a/doc/lua_api.txt b/doc/lua_api.txt
index e4a016b1a02dbde269606c6dccb0036bf3fdf1d6..f51d215edd8a291a3ae48e33feca8c5a2ef078f6 100644
--- a/doc/lua_api.txt
+++ b/doc/lua_api.txt
@@ -1310,6 +1310,8 @@ minetest.is_yes(arg)
 ^ returns whether arg can be interpreted as yes
 minetest.get_us_time()
 ^ returns time with microsecond precision
+table.copy(table) -> table
+^ returns a deep copy of a table
 
 minetest namespace reference
 -----------------------------