diff --git a/cmd/tools/vfmt.v b/cmd/tools/vfmt.v
index 296f4de1b0..b7f9ff8be2 100644
--- a/cmd/tools/vfmt.v
+++ b/cmd/tools/vfmt.v
@@ -100,7 +100,7 @@ fn main() {
 	for file in files {
 		fpath := os.real_path(file)
 		mut worker_command_array := cli_args_no_files.clone()
-		worker_command_array << ['-worker', fpath]
+		worker_command_array << ['-worker', util.quote_path_with_spaces(fpath)]
 		worker_cmd := worker_command_array.join(' ')
 		if foptions.is_verbose {
 			eprintln('vfmt worker_cmd: $worker_cmd')
diff --git a/vlib/v/util/util.v b/vlib/v/util/util.v
index 65e60ff86f..5392e068ff 100644
--- a/vlib/v/util/util.v
+++ b/vlib/v/util/util.v
@@ -102,7 +102,7 @@ pub fn launch_tool(is_verbose bool, tool_name string) {
 	vexe := pref.vexe_path()
 	vroot := os.dir(vexe)
 	set_vroot_folder(vroot)
-	tool_args := os.args[1..].join(' ')
+	tool_args := args_quote_paths_with_spaces(os.args[1..])
 	tool_exe := path_of_executable(os.real_path('$vroot/cmd/tools/$tool_name'))
 	tool_source := os.real_path('$vroot/cmd/tools/${tool_name}.v')
 	tool_command := '"$tool_exe" $tool_args'
@@ -162,6 +162,21 @@ pub fn launch_tool(is_verbose bool, tool_name string) {
 	exit(os.system(tool_command))
 }
 
+pub fn quote_path_with_spaces(s string) string {
+	if s.contains(' ') {
+		return '"${s}"'
+	}
+	return s
+}
+
+pub fn args_quote_paths_with_spaces(args []string) string {
+	mut res := []string{}
+	for a in args {
+		res << quote_path_with_spaces( a )
+	}
+	return res.join(' ')
+}
+
 pub fn path_of_executable(path string) string {
 	$if windows {
 		return path + '.exe'