{"name":"format","title":"format","type":"command","url":"https://community.bistudio.com/wiki/format","revid":378210,"updated":"2026-03-13T14:09:11Z","groups":["Strings"],"status":"ok","games":{"ofp":"1.00","ofpe":"1.00","arma1":"1.00","arma2":"1.00","arma2oa":"1.50","tkoh":"1.00","arma3":"0.50"},"since":"ofp 1.00","arma3_since":"0.50","description":"Composes a string containing other variables or other variable types. Converts any variable type to a string.\n\n> [!IMPORTANT]\n> - To convert a string back to a number, see parseNumber.\n> - joinString can be a bit faster, without string length limitation.\n\n> [!NOTE]\n> - the maximum length of the string is 8,388,608 characters (was *8191* before)\n> - two consecutive percent symbols will be formatted to a single percent symbol in the final string (see Example 3)\n>\n> Since Arma 3 v2.18","syntaxes":[{"syntax":"format [formatString, var1, var2, ...]","params":[{"name":"formatString","type":"String","description":"a string containing text and/or references to the variables listed below in the array. The references appear in the form of %1, %2 etc.","type_expr":"String"},{"name":"varN","type":"Anything","description":"variable referenced by %N","type_expr":"Anything"}],"returns":{"type":"String","type_expr":"String","description":"the full string (up to 8kb, see above) is returned."},"form":"unary","right":{"text":"[formatString, var1, var2, ...]"}}],"examples":[{"code":["format [\"Player:%1, player's side:%2\", player, side player]; // returns \"Player:WEST 1-1-A:1 (Username), player's side:WEST\""]},{"text":"```sqf\nplayer addEventHandler [\"HandleDamage\", {\n    hint format [\"You just sustained %1%2 damage!\", ceil ((_this select 2) * 100), \"%\"];\n}]; // Shows \"You just sustained 20% damage!\"\n```","code":["player addEventHandler [\"HandleDamage\", {\n\thint format [\"You just sustained %1%2 damage!\", ceil ((_this select 2) * 100), \"%\"];\n}]; // Shows \"You just sustained 20% damage!\""]},{"text":"```sqf\n// Since Arma 3 v2.18 two consecutive percent symbols will be formatted to a single percent symbol in the final string (%% -> %)\nplayer addEventHandler [\"HandleDamage\", {\n    hint format [\"You just sustained %1%% damage!\", ceil ((_this select 2) * 100)];\n}]; // Shows \"You just sustained 20% damage!\"\n```","code":["// Since Arma 3 v2.18 two consecutive percent symbols will be formatted to a single percent symbol in the final string (%% -> %)\nplayer addEventHandler [\"HandleDamage\", {\n\thint format [\"You just sustained %1%% damage!\", ceil ((_this select 2) * 100)];\n}]; // Shows \"You just sustained 20% damage!\""]}],"see_also":["formatText","endl","str","toString","joinString"],"notes":[{"user":"Worldeater","date":"2009-03-02T15:12:00Z","text":"The maximum number of characters returned by the *format* command seems to depend on the total byte count. For plain ASCII strings the limit is 2048 characters."},{"user":"Heeeere's Johnny!","date":"2015-03-28T09:22:00Z","text":"In addition to the note above, formatTexted strings are Structured Text, hence cannot be used like formatted strings (with most scripting commands). A workaround to get strings of type String with more than 8191 characters is:\n\n```sqf\nstr formatText [\"%1\", _string]\n```"}]}