RealDocs

FString::Format

function Core Since 4.7
#include "Containers/UnrealString.h"
Access: public Specifiers: static

Description

Builds a string by substituting {Name} or {0}/{1}/... tokens in InFormatString with values from a named or ordered argument collection.

Signature

static FString Format( const TCHAR* InFormatString, const TMap<FString, FStringFormatArg>& InNamedArguments )

Parameters

Name Type Description Default
InFormatString const TCHAR* A format string containing {Name} or {0} tokens to replace.
InNamedArguments / InOrderedArguments const TMap<FString, FStringFormatArg>& or const TArray<FStringFormatArg>& Named arguments ({Name} tokens) or ordered arguments ({0}, {1} tokens). Two overloads exist.

Return Type

FString

Caveats & Gotchas

  • FString::Format uses braces {} as delimiters, not % like Printf. These two functions are not interchangeable.
  • Named argument keys are case-sensitive. {Health} and {health} are treated as different tokens.
  • Slightly slower than FString::Printf due to the token-scanning pass — prefer Printf for performance-critical paths.

Examples

Format with ordered arguments C++
FString Result = FString::Format(
	TEXT("Hello {0}, you have {1} coins"),
	{ PlayerName, FString::FromInt(Coins) }
);
Format with named arguments C++
FStringFormatNamedArguments Args;
Args.Add(TEXT("Name"), PlayerName);
Args.Add(TEXT("Score"), Score);
FString Result = FString::Format(TEXT("Player {Name} scored {Score}"), Args);

Version History

Introduced in: 4.7

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.