diff --git a/test/app-tap/console.test.lua b/test/app-tap/console.test.lua
index f055958c6d39fd2184af0cb891a3243c7eb2250d..1c76072aa6513c7fcfdf7ce618973cfc2f82064c 100755
--- a/test/app-tap/console.test.lua
+++ b/test/app-tap/console.test.lua
@@ -21,7 +21,7 @@ local EOL = "\n...\n"
 
 test = tap.test("console")
 
-test:plan(53)
+test:plan(57)
 
 -- Start console and connect to it
 local server = console.listen(CONSOLE_SOCKET)
@@ -67,6 +67,14 @@ test:is(yaml.decode(client:read(EOL))[1], ';', "get delimiter is ';'")
 client:write("require('console').delimiter('');\n")
 test:is(yaml.decode(client:read(EOL)), '', "clear delimiter")
 
+--
+-- gh-3476: yaml.encode encodes 'false' and 'true' incorrectly.
+--
+test:is(type(yaml.decode(yaml.encode('false'))), 'string')
+test:is(type(yaml.decode(yaml.encode('true'))), 'string')
+test:is(type(yaml.decode(yaml.encode({a = 'false'})).a), 'string')
+test:is(type(yaml.decode(yaml.encode({a = 'false'})).a), 'string')
+
 box.cfg{
     listen=IPROTO_SOCKET;
     memtx_memory = 107374182,
diff --git a/third_party/lua-yaml/lyaml.cc b/third_party/lua-yaml/lyaml.cc
index 14eabca7729e725d855b54a822171c3817c134c9..c6d118a79b61ca8130e4f99d6cc0448f37449393 100644
--- a/third_party/lua-yaml/lyaml.cc
+++ b/third_party/lua-yaml/lyaml.cc
@@ -605,9 +605,12 @@ static int dump_node(struct lua_yaml_dumper *dumper)
       if (utf8_check_printable(str, len)) {
          if (yaml_is_flow_mode(dumper)) {
             style = YAML_SINGLE_QUOTED_SCALAR_STYLE;
-         } else if (strstr(str, "\n\n") != NULL) {
+         } else if (strstr(str, "\n\n") != NULL || strcmp(str, "true") == 0 ||
+		    strcmp(str, "false") == 0) {
             /*
-             * Tarantool-specific: use literal style for string with empty lines.
+             * Tarantool-specific: use literal style for string
+             * with empty lines and strings representing boolean
+             * types.
              * Useful for tutorial().
              */
             style = YAML_LITERAL_SCALAR_STYLE;