# General Translation Platform: formatListToParts
URL: https://generaltranslation.com/en-US/docs/platform/core/reference/utility-functions/formatting/format-list-to-parts.mdx
Docs index: https://generaltranslation.com/llms.txt
Description: Format a list into locale-aware parts without a GT instance. API reference for formatListToParts.

[`formatListToParts`](/docs/platform/core/reference/gt-class-methods/formatting/format-list-to-parts) is a standalone utility function from General Translation's Core library that formats an array into locale-specific parts. It inserts string separators between items while preserving the original type of each element, returning an `Array<T | string>`.

## Overview [#overview]

Import `formatListToParts` directly from `generaltranslation` and call it with an array and an options object. It does not require an API key or a [GT](/docs/platform/core/reference/gt-class/constructor) instance. For instance-based formatting that inherits the instance locale, use the [`formatListToParts`](/docs/platform/core/reference/gt-class-methods/formatting/format-list-to-parts) method on a [`GT`](/docs/platform/core/reference/gt-class/constructor) instance instead.

Unlike [`formatList`](/docs/platform/core/reference/utility-functions/formatting/format-list), which returns a flat `string`, this function keeps the original items intact and only inserts string separators between them — useful for rendering mixed-type arrays in UI frameworks such as React.

```typescript
import { formatListToParts } from 'generaltranslation';

const parts = formatListToParts(['red', 'green', 'blue'], {
  locales: ['es'],
  type: 'disjunction',
});
// Returns: ['red', ', ', 'green', ' o ', 'blue']
```

Signature:

```typescript
formatListToParts<T>(
  array: Array<T>,
  options?: { locales?: string | string[] } & Intl.ListFormatOptions
): Array<T | string>
```

## How it works [#how-it-works]

- **Underlying API.** Uses the same [`Intl.ListFormat`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat) as the GT class method.
- **Type preservation.** Only string separators are inserted between elements; every original item keeps its type, so numbers and objects pass through unchanged.
- **Locale resolution.** When `locales` is omitted, it falls back to the library default locale, `en`.

## Parameters [#parameters]

| Parameter | Description | Type | Optional | Default |
| --- | --- | --- | --- | --- |
| [`array`](#array) | The array of items to format. | `Array<T>` | No | — |
| [`options`](#options) | Formatting configuration, including the target locale(s). | `{ locales?: string \| string[] } & Intl.ListFormatOptions` | Yes | `{}` |

### `array` [#array]

**Type** `Array<T>` · **Required**

The array of items to format. Items of any type are supported; non-string items are returned unchanged.

### `options` [#options]

**Type** `{ locales?: string | string[] } & Intl.ListFormatOptions` · **Optional** · **Default** `{}`

Formatting configuration. The table lists common options exposed by the published Core types and their effective Core defaults. (See the [`Intl.ListFormat` constructor options](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/ListFormat#options) for supplemental standard and runtime-specific details).

| Property | Description | Type | Optional | Default |
| --- | --- | --- | --- | --- |
| `locales` | Locale(s) for formatting. | `string \| string[]` | Yes | `en` |
| `localeMatcher` | Locale matching algorithm. | `'lookup' \| 'best fit'` | Yes | `'best fit'` |
| `type` | List formatting type. | `'conjunction' \| 'disjunction' \| 'unit'` | Yes | `'conjunction'` |
| `style` | List formatting style. | `'long' \| 'short' \| 'narrow'` | Yes | `'long'` |

## Returns [#returns]

**Type** `Array<T | string>`

An array of the original items interleaved with locale-specific string separators.

## Examples [#examples]

```typescript
import { formatListToParts } from 'generaltranslation';

// Conjunction list (default)
console.log(formatListToParts(['A', 'B', 'C'], { locales: 'en' }));
// Output: ['A', ', ', 'B', ', and ', 'C']

// Disjunction list
console.log(formatListToParts(['A', 'B', 'C'], { locales: 'en', type: 'disjunction' }));
// Output: ['A', ', ', 'B', ', or ', 'C']
```

```typescript
// Mixed-type arrays: numbers and objects are preserved
console.log(formatListToParts(['apple', 42, { type: 'fruit' }], { locales: 'en' }));
// Output: ['apple', ', ', 42, ', and ', { type: 'fruit' }]
```

```typescript
// Spanish disjunction
console.log(formatListToParts(['red', 'green', 'blue'], {
  locales: 'es',
  type: 'disjunction',
}));
// Output: ['red', ', ', 'green', ' o ', 'blue']

// Short style
console.log(formatListToParts(['first', 'second'], {
  locales: 'en',
  style: 'short',
}));
// Output: ['first', ' & ', 'second']
```

## Notes [#notes]

- Original item types are preserved — only string separators are inserted between elements.
- This is the key differentiator from [`formatList`](/docs/platform/core/reference/utility-functions/formatting/format-list), which returns a flat `string`.
- Particularly useful for rendering mixed-type arrays in UI frameworks like React.
- Uses the same underlying `Intl.ListFormat` as the GT class method.

## Sitemap

See the full [sitemap](https://generaltranslation.com/sitemap.md) for all pages.
