---
name: "format"
type: command
status: ok
groups: ["Strings"]
arma3_since: "0.50"
locality: {"argument": null, "effect": null, "server_exec": false}
source: https://community.bistudio.com/wiki/format
revid: 378210
updated: 2026-03-13T14:09:11Z
---

# format

*Command · Strings · Arma 3 v0.50 · introduced in Operation Flashpoint v1.00*

## Description

Composes a string containing other variables or other variable types. Converts any variable type to a string.

> [!IMPORTANT]
> - To convert a string back to a number, see [parseNumber](../commands/parseNumber.md).
> - [joinString](../commands/joinString.md) can be a bit faster, without string length limitation.

> [!NOTE]
> - the maximum length of the string is 8,388,608 characters (was *8191* before)
> - two consecutive percent symbols will be formatted to a single percent symbol in the final string (see [#Example 3](../commands/format.md#example-3))
> Since Arma 3 v2.18

## Syntax

```sqf
format [formatString, var1, var2, ...]
```

**Parameters:**

- `formatString`: [String](../topics/String.md) - 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.
- `varN`: [Anything](../topics/Anything.md) - variable referenced by %N

**Returns:** [String](../topics/String.md) - the full string (up to 8kb, see above) is returned.

## Examples

### Example 1

```sqf
format ["Player:%1, player's side:%2", player, side player]; // returns "Player:WEST 1-1-A:1 (Username), player's side:WEST"
```

### Example 2

```sqf
player addEventHandler ["HandleDamage", {
    hint format ["You just sustained %1%2 damage!", ceil ((_this select 2) * 100), "%"];
}]; // Shows "You just sustained 20% damage!"
```

### Example 3

```sqf
// Since Arma 3 v2.18 two consecutive percent symbols will be formatted to a single percent symbol in the final string (%% -> %)
player addEventHandler ["HandleDamage", {
    hint format ["You just sustained %1%% damage!", ceil ((_this select 2) * 100)];
}]; // Shows "You just sustained 20% damage!"
```

## See also

[formatText](../commands/formatText.md) · [endl](../commands/endl.md) · [str](../commands/str.md) · [toString](../commands/toString.md) · [joinString](../commands/joinString.md)

## Community notes

**Worldeater** — 2009-03-02

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.

---

**Heeeere's Johnny!** — 2015-03-28

In addition to the note above, [formatText](../commands/formatText.md)ed strings are [Structured Text](../topics/Structured_Text.md), hence cannot be used like [format](../commands/format.md)ted strings (with most scripting commands). A workaround to get strings of type [String](../topics/String.md) with more than 8191 characters is:

```sqf
str formatText ["%1", _string]
```

<sub>Source: [BI Community Wiki — format](https://community.bistudio.com/wiki/format) (revision 378210).</sub>
