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

> ## Agent Instructions
> FalkorDB is a graph database that speaks the Redis protocol. Queries are issued as OpenCypher through the GRAPH.QUERY and GRAPH.RO_QUERY commands, not over Bolt or a SQL connection.
> FalkorDB implements a subset of OpenCypher with proprietary extensions. Do not assume Neo4j-only syntax or procedures are available — check /cypher/cypher-support and /cypher/known-limitations before using a clause.
> FalkorDB is the successor to RedisGraph, but they are separate products. Do not present RedisGraph commands, versions, or limitations as current FalkorDB behavior.
> Use the official clients listed in /getting-started/clients rather than generic Redis or Neo4j drivers, and prefer the language the user is already working in.
> Configuration parameters are set with GRAPH.CONFIG SET or at startup; cite the exact parameter name from /getting-started/configuration rather than inventing one.
> This site covers four products: FalkorDB (core), FalkorDB Cloud, FalkorDB Enterprise, and the GraphRAG SDK. Name which one an answer applies to, since setup and operations differ.

# 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>
