To golang bool to string (also searched as bool to string golang, golang convert bool to string, go bool to string, or boolean to string golang), use strconv.FormatBool for the clearest API, or fmt.Sprintf when you are already formatting a larger message (golang sprintf bool with the %t verb). The reverse—golang string to bool—uses strconv.ParseBool. You cannot compare a bool to the string "true" without converting one side; see string comparison in Go after both sides are strings. For format verbs in general, see string interpolation in Go; for variable types and scope.
Tested with Go 1.24 on Linux.
%t prints booleans; %v uses the default format for any type. Prefer FormatBool when the value is only a bool.
strconv.FormatBool (preferred)
func FormatBool(b bool) string returns "true" or "false":
package main
import (
"fmt"
"strconv"
)
func main() {
v := true
s := strconv.FormatBool(v)
fmt.Printf("%T %v\n", v, v)
fmt.Printf("%T %q\n", s, s)
}You should see bool true then string "true".
fmt.Sprintf — golang sprintf bool
Use %t for booleans; %v also works but is less explicit when the argument list mixes types:
package main
import "fmt"
func main() {
b := false
fmt.Println(fmt.Sprintf("%t", b))
fmt.Println(fmt.Sprintf("enabled=%v", true))
}You should see false then enabled=true.
golang string to bool with ParseBool
strconv.ParseBool accepts 1, t, T, TRUE, true, True, 0, f, F, FALSE, false, False (see docs):
package main
import (
"fmt"
"strconv"
)
func main() {
for _, s := range []string{"true", "0", "maybe"} {
v, err := strconv.ParseBool(s)
fmt.Println(s, v, err)
}
}You should see true true <nil>, 0 false <nil>, and a non-nil error for maybe.
Do not compare bool to a string literal
This does not compile:
var v bool = true
if v == "true" { } // invalid operation: bool == untyped stringConvert with FormatBool / ParseBool or compare two strings after conversion.
Summary
For convert bool to string golang and go convert bool to string, strconv.FormatBool is the smallest and fastest option; fmt.Sprintf("%t", b) covers golang sprintf bool when building larger messages. For golang string to bool, use strconv.ParseBool and handle errors. That keeps logs, flags, and JSON-adjacent text consistent without illegal bool vs string comparisons.

