Format Strings

Format Strings

In some applications, Roblox uses locale-aware format strings as patterns for string matching and reformatting. For instance, format strings can be used with LocalizationService automatic text replacement and the Translator APIs.


Parameters in format strings are denoted with curly braces like {1}. Parameters must be explicitly numbered or named for recognition.

Remember these rules when using parameters in format strings:

  • Numbered parameters use 1-based indexing like {1}, {2}, etc.
  • Named parameters look like {user} or {item}.
  • Named and numbered parameters cannot be mixed in the same format string!
  • The empty string indicator {} can be used to represent an empty string, but there must be no characters before or after the brackets (otherwise it will be invalid).
  • Curly braces in text must be escaped like {{ or }}.

Format Specifiers

Format specifiers are used to control how a parameter value is formatted. They can be used for locale-aware numbers, dates, and time formatting.

Format specifiers can be noted after the parameter name/index, separated by :, for instance:

  • {1:int}
  • {2:fixed}
  • {gametime:shorttime}
Specifier Type Description Example Output
int number Integer with optional negative sign; no thousand separators. 1234
fixed number Two decimals with decimal indicator, optional negative sign, and no thousand separators. 1234.50
num number Two decimals with decimal indicator, optional negative sign, and thousand separators. 1,234.50
1 234,50
HEX number Integer converted to hex; negative is converted to 64-bit two's complement. 3FF
hex number Same as HEX, but lowercase. 3ff
datetime number UTC timestamp as a number to universal user-readable format. 2017-10-10 13:38:10
iso8601 number UTC timestamp as a number to ISO-8601 format UTC time. 2017-10-12T22:02:38Z
shorttime number UTC timestamp to local "hour:minute" format. 1:45 PM
shortdatetime number UTC timestamp to general date+time pattern with short time. 10/10/2017 1:45 PM
shortdate number UTC timestamp to short date pattern. 10/10/2017
translate string Attempts to translate the argument before concatenating (in the same context). This will only look for a literal Source match — it does not support recursive matching.
(nothing) string Inserts string.
(nothing) number int if integral; fixed if not.

Localization Matches

Format strings are often used in Articles/Roblox Localization Tools|game localization. In this application, if a LocalizationTable entry contains a non-empty format string within Source, it will be used for matching.

Consider these example translations from a CSV import file:

Source es-es
${1} Cash ${1} Efectivo
Hello {user}! Hola {user}!

If this is properly imported into LocalizationService and you have a GUI TextLabel that reads “$1000 Cash,” auto-localization will make it render as “$1000 Efectivo” for Spanish players.

Additionally, Translator/Translate|Translator:Translate() can be used to return a translated string, for example:

  • localization
  • language
  • translation
  • format