diff --git a/src/lua/init.cc b/src/lua/init.cc
index 394b204f048f46c9d661f7cc4c8f0ab5fdd891b7..0dccc9f95caba0119d20e166fd4ab4da0c4560a9 100644
--- a/src/lua/init.cc
+++ b/src/lua/init.cc
@@ -663,10 +663,18 @@ tarantool_lua(struct lua_State *L,
 	lua_newtable(L);
 	for (int i = 1; i <= top; i++) {
 		lua_pushnumber(L, i);
-		if (lua_isnil(L, i))
+		if (lua_isnil(L, i)) {
+			/**
+			 * When storing a nil in a Lua table,
+			 * there is no way to distinguish nil
+			 * value from no value. This is a trick
+			 * to make sure yaml converter correctly
+			 * outputs nil values on the return stack.
+			 */
 			lua_pushlightuserdata(L, NULL);
-		else
+		} else {
 			lua_pushvalue(L, i);
+		}
 		lua_rawset(L, -3);
 	}
 	lua_replace(L, 1);
diff --git a/test/big/tree_pk_multipart.result b/test/big/tree_pk_multipart.result
index edd9fbd95d27a48b03be46e9d782788e744a37ad..31adc49e680fb4d3b372f70ff3637d5d49370864 100644
--- a/test/big/tree_pk_multipart.result
+++ b/test/big/tree_pk_multipart.result
@@ -395,7 +395,7 @@ k,v = space.index[1]:next(k)
 ...
 v
 ---
-{}
+- null
 ...
 collectgarbage('collect')
 ---
@@ -403,7 +403,7 @@ collectgarbage('collect')
 ...
 v
 ---
-{}
+- null
 ...
 t = {}
 ---
diff --git a/test/box/alter.result b/test/box/alter.result
index 7d78da47fb602b2907068790d35466a44365a878..5e54f331de9e2329fbebc10e36cc5367bcab87f9 100644
--- a/test/box/alter.result
+++ b/test/box/alter.result
@@ -94,7 +94,7 @@ space.arity
 ...
 space.index[0]
 ---
-{}
+- null
 ...
 --
 -- check dml - the space has no indexes yet, but must not crash on DML
@@ -127,7 +127,7 @@ space_deleted = box.space[box.unpack('i', t[0])]
 ...
 space_deleted
 ---
-{}
+- null
 ...
 space:replace(0)
 ---
@@ -179,5 +179,5 @@ box.space[1000]:drop()
 ...
 box.space[1000]
 ---
-{}
+- null
 ...
diff --git a/test/box/fiber.result b/test/box/fiber.result
index ff6dd688e9e91e8d190b77a52319d500d64d2329..e1cd4b41f7a26e121d6772695791c469a0a775e0 100644
--- a/test/box/fiber.result
+++ b/test/box/fiber.result
@@ -271,15 +271,15 @@ collectgarbage('collect')
 -- check that these newly created fibers are garbage collected
 box.fiber.find(900)
 ---
-{}
+- null
 ...
 box.fiber.find(910)
 ---
-{}
+- null
 ...
 box.fiber.find(920)
 ---
-{}
+- null
 ...
 space:drop()
 ---
diff --git a/test/box/info.result b/test/box/info.result
index 6e495a32dbca24e0d797767b255c02765d771243..d3d8d0d21f9bf17a21fbea284500a45e02653dab 100644
--- a/test/box/info.result
+++ b/test/box/info.result
@@ -2,15 +2,15 @@
 -- make sure it's a valid YAML
 box.info.unknown_variable
 ---
-{}
+- null
 ...
 box.info[23]
 ---
-{}
+- null
 ...
 box.info['unknown_variable']
 ---
-{}
+- null
 ...
 string.match(box.info.version, '^[1-9]') ~= nil
 ---
diff --git a/test/box/ipc.result b/test/box/ipc.result
index 3909a516fa11efedfc1d37ea6c5f08a87bdb3f18..944381fc49b6ad62b911fcf3f6fe74cb1e467be6 100644
--- a/test/box/ipc.result
+++ b/test/box/ipc.result
@@ -11,7 +11,7 @@ ch:is_empty()
 ...
 ch:get(.1)
 ---
-{}
+- null
 ...
 ch:put()
 ---
diff --git a/test/box/lua.result b/test/box/lua.result
index 964f54eab7d3b0bf100868a312022f777fd48030..6cff707a912d58567983d8bdeb7fd1bd299a51d5 100644
--- a/test/box/lua.result
+++ b/test/box/lua.result
@@ -230,6 +230,7 @@ f1()
 - -1
 - 1.123
 - 1e+123
+- null
 ...
 call f1()
 Found 7 tuples:
@@ -749,6 +750,8 @@ f=box.fiber.create(r)
 box.fiber.resume(f)
 ---
 - true
+- null
+- null
 ...
 f=box.fiber.create(r)
 ---
@@ -757,6 +760,7 @@ box.fiber.resume(f, 'hello')
 ---
 - true
 - hello
+- null
 ...
 f=box.fiber.create(r)
 ---
@@ -826,15 +830,15 @@ collectgarbage('collect')
 ...
 box.fiber.find(900)
 ---
-{}
+- null
 ...
 box.fiber.find(910)
 ---
-{}
+- null
 ...
 box.fiber.find(920)
 ---
-{}
+- null
 ...
 f = function() box.fiber.wrap(f) end
 ---
@@ -860,7 +864,7 @@ result
 ...
 box.fiber.wrap(function() result = box.fiber.status() end)
 ---
-{}
+- null
 ...
 result
 ---
@@ -1379,7 +1383,7 @@ box.space[0]:truncate()
 
 ffi
 ---
-{}
+- null
 ...
 
 #
diff --git a/test/box/lua_misc.result b/test/box/lua_misc.result
index a4cbf5703075b4339b8127be8bc952ea304d3399..9c5b84b88c38fb49f09a52ce732475d3d19deceb 100644
--- a/test/box/lua_misc.result
+++ b/test/box/lua_misc.result
@@ -73,7 +73,7 @@ type(box.space);
 ...
 box.cfg.memcached_space;
 ---
-{}
+- null
 ...
 t = {};
 ---
diff --git a/test/box/net.box.result b/test/box/net.box.result
index d0c9c6f10478230cab865b9e29b06e7cfa0f7833..9062bde9dd1089474ee63a6e637ef07ccae37573 100644
--- a/test/box/net.box.result
+++ b/test/box/net.box.result
@@ -126,7 +126,7 @@ remote:call('box.fiber.sleep', '.01')
 ...
 remote:timeout(0.01):call('box.fiber.sleep', '10')
 ---
-{}
+- null
 ...
 -- setopt delimiter ';'
 pstart = box.time();
diff --git a/third_party/lua-yaml/lyaml.c b/third_party/lua-yaml/lyaml.c
index f9aab98f035247af447ab7de4d925ff524755012..968591c972ee908c72b8473114628589f7433f27 100644
--- a/third_party/lua-yaml/lyaml.c
+++ b/third_party/lua-yaml/lyaml.c
@@ -443,9 +443,9 @@ static int dump_scalar(struct lua_yaml_dumper *dumper) {
    } else if (type == LUA_TLIGHTUSERDATA) {
 		void *ptr = luaL_checkudata(dumper->L, -1, NULL);
 		if (ptr == NULL) {
-	        str = "null";
-	        len = 4;
-	        style = YAML_PLAIN_SCALAR_STYLE;
+			str = "null";
+			len = 4;
+			style = YAML_PLAIN_SCALAR_STYLE;
 		} else {
 			str = dump_tostring(dumper->L, -1);
 			len = strlen(str);