{ }Blueprint → C++

Unreal Engine 5 · Blueprint → C++

Convert To String in Unreal Engine 5 C++UE Docs

The Blueprint To String node converts a value to text. In Unreal Engine 5 C++ you use FString::FromInt for integers, FString::SanitizeFloat for floats, and LexToString for bools and many other types.

Blueprint node & C++ equivalent

C++
FString FromInt   = FString::FromInt(42);
FString FromFloat = FString::SanitizeFloat(3.14f);
FString FromBool  = LexToString(true);

The C++ equivalent of To String

Each type has its own conversion: FString::FromInt(42) turns an int32 into "42", FString::SanitizeFloat(3.14f) converts a float into a clean decimal string, and LexToString(true) produces "true" from a bool. SanitizeFloat is preferred over a raw cast because it trims trailing zeros and produces readable output.

When to use each function

Use FString::FromInt for integer counters, scores, and IDs. Use FString::SanitizeFloat when displaying floats where you want a tidy representation. LexToString is a generic, templated helper that works across bools, numbers, and other primitive types, making it handy when you write template code or want one consistent call.

Common mistakes

Do not try to add a number directly to an FString with operator+; convert it first. For controlled decimal places, FString::SanitizeFloat gives a clean result, but if you need a fixed number of digits use FString::Printf(TEXT("%.2f"), Value) instead.

Frequently asked questions

How do you convert an int to a string in UE5 C++?+

Call FString::FromInt(MyInt). It returns an FString containing the decimal representation of the integer.

How do you convert a float to a string in Unreal Engine 5?+

Use FString::SanitizeFloat(MyFloat) for clean output, or FString::Printf(TEXT("%.2f"), MyFloat) when you need a fixed number of decimal places.

How do you convert a bool to a string in UE5?+

Use LexToString(bValue), which returns "true" or "false". LexToString is a generic helper that also works for numeric types.

Related Strings, Text & Names nodes

View all Strings, Text & Names nodes →