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

> Reference material for STRING_TO_ARRAY function

# STRING_TO_ARRAY

Splits a string into an array of strings based on a specified delimiter, with the following behaviors:

* If the delimiter is an empty string `''`, the result is an array containing the entire original input string as a single element.
* If the delimiter is `NULL`, the string is split into individual characters, with one character per array element.

## Syntax

```sql theme={"theme":{"light":"css-variables","dark":"css-variables"}}
STRING_TO_ARRAY(<string>, <delimiter>)
```

## Parameters

| Parameter     | Description                           |
| :------------ | :------------------------------------ |
| `<string>`    | The string to split.                  |
| `<delimiter>` | The separator to split the string by. |

## Return Types

`ARRAY(TEXT)`

## Examples

**Example**

The following code example splits the string `stephen70|esimpson|ruthgill|` at each `|` character and returns the resulting array as `nicknames`:

<div className="query-window">
  ```
  SELECT STRING_TO_ARRAY('stephen70|esimpson|ruthgill|', '|') AS nicknames;
  ```

  | nicknames <span>array(text)</span>         |
  | :----------------------------------------- |
  | \['stephen70', 'esimpson', 'ruthgill', ''] |

  <p><span>Rows: 1</span><span>Execution time: 5.37ms</span></p>
</div>

**Example**

The following code example calls `STRING_TO_ARRAY` with an empty delimiter, producing an array containing a single element which contains the input text:

<div className="query-window">
  ```
  SELECT STRING_TO_ARRAY('firebolt', '') AS size_one_array;
  ```

  | size\_one\_array <span>array(text)</span> |
  | :---------------------------------------- |
  | \['firebolt']                             |

  <p><span>Rows: 1</span><span>Execution time: 7.91ms</span></p>
</div>

**Example**

The following example calls `STRING_TO_ARRAY` with `NULL` as the delimiter, splitting the text into individual characters:

<div className="query-window">
  ```
  SELECT STRING_TO_ARRAY('firebolt', NULL) AS single_characters;
  ```

  | single\_characters <span>array(text)</span> |
  | :------------------------------------------ |
  | \['f', 'i', 'r', 'e', 'b', 'o', 'l', 't']   |

  <p><span>Rows: 1</span><span>Execution time: 5.72ms</span></p>
</div>
