{ }Blueprint → C++

Unreal Engine 5 · Blueprint → C++

Format Text in Unreal Engine 5 C++UE Docs

The Blueprint Format Text node maps to FText::Format in Unreal Engine 5 C++, which substitutes numbered arguments like {0} into a localizable FText pattern.

Blueprint node & C++ equivalent

C++
FText T = FText::Format(
  NSLOCTEXT("Game", "ScoreFmt", "{0} points"), FText::AsNumber(Score));

The C++ equivalent of Format Text

FText::Format takes a format pattern and one or more FText arguments, replacing placeholders such as {0} and {1}. In the snippet, NSLOCTEXT("Game", "ScoreFmt", "{0} points") defines a localizable pattern in the "Game" namespace with key "ScoreFmt", and FText::AsNumber(Score) supplies the {0} argument as culture-aware formatted text.

Why FText instead of FString

FText is the type for user-facing, localized text. Unlike FString::Printf, FText::Format keeps the pattern translatable and formats numbers according to the active culture, so thousands separators and decimal symbols follow the player's locale. Always feed it FText arguments produced by helpers like FText::AsNumber, FText::AsPercent, or FText::FromString.

When to use it

Use FText::Format for any text shown to players: HUD labels, dialogue, menus, and tooltips. Reserve FString::Printf for logs and internal strings that never get translated. The NSLOCTEXT macro registers the string with the localization system at the given namespace and key.

Frequently asked questions

How do you format FText in Unreal Engine 5 C++?+

Use FText::Format(Pattern, Args...) where the pattern contains numbered placeholders like {0} and arguments are FText values, for example from FText::AsNumber.

What is the difference between NSLOCTEXT and LOCTEXT?+

NSLOCTEXT takes an explicit namespace argument, while LOCTEXT uses the file-wide LOCTEXT_NAMESPACE macro. Both register a localizable FText with a namespace and key.

Should I use FText::Format or FString::Printf?+

Use FText::Format for localized, player-facing text so it can be translated and culture-formatted. Use FString::Printf for non-localized strings like debug logs.

Related Strings, Text & Names nodes

View all Strings, Text & Names nodes →