> ## Documentation Index
> Fetch the complete documentation index at: https://new.docs.falkordb.com/llms.txt
> Use this file to discover all available pages before exploring further.

# text.format

> Formats a string by replacing numbered placeholders {0}, {1}, etc. with values from a parameters array.

## Description

Formats a string by replacing numbered placeholders `{0}`, `{1}`, `{2}`, etc. with corresponding values from a parameters array. Similar to sprintf-style formatting.

## Syntax

```cypher theme={null}
flex.text.format(template, parameters)
```

## Parameters

| Parameter    | Type   | Required | Description                                                  |
| ------------ | ------ | -------- | ------------------------------------------------------------ |
| `template`   | string | Yes      | The format string containing `{0}`, `{1}`, etc. placeholders |
| `parameters` | list   | Yes      | Array of values to substitute into the template              |

## Returns

**Type:** string

The formatted string with placeholders replaced by parameter values. Returns `null` if template is `null`.

## Examples

### Example 1: Basic String Formatting

```cypher theme={null}
RETURN flex.text.format('Hello {0}, you are {1} years old!', ['Alice', 30]) AS result
```

**Output:**

```text theme={null}
result
--------------------------------
Hello Alice, you are 30 years old!
```

### Example 2: Dynamic Query Messages

```cypher theme={null}
MATCH (u:User {id: 123})
WITH u, flex.text.format('User {0} ({1}) logged in at {2}', [u.name, u.email, u.lastLogin]) AS message
RETURN message
```

### Example 3: Building URLs or Paths

```cypher theme={null}
WITH ['users', 'profile', '12345'] AS parts
RETURN flex.text.format('/{0}/{1}/{2}', parts) AS path
```

**Output:**

```text theme={null}
path
------------------------
/users/profile/12345
```

## Notes

* Returns `null` if template is `null`
* Placeholders are zero-indexed: `{0}`, `{1}`, `{2}`, etc.
* Same placeholder can be used multiple times in template
* Parameters are replaced in order of array index
* Useful for building dynamic messages, logs, or formatted output

## See Also

* [text.replace](/udfs/flex/text/replace) - Replace text using regex patterns
* [text.join](/udfs/flex/text/join) - Join array elements with delimiter

## Frequently Asked Questions

<AccordionGroup>
  <Accordion title="How are placeholders numbered in flex.text.format?">
    Placeholders are zero-indexed: `{0}` is replaced by the first element, `{1}` by the second, and so on.
  </Accordion>

  <Accordion title="Can I reuse the same placeholder multiple times?">
    Yes. The same placeholder (e.g., `{0}`) can appear multiple times in the template and will be replaced with the same value each time.
  </Accordion>
</AccordionGroup>
