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

# Format to selected format

> Converts a data object into the desired output format.

export const FormField = ({property, label, required = false, diType, uiPatterns, children}) => {
  const patterns = Array.isArray(uiPatterns) ? uiPatterns : uiPatterns ? [uiPatterns] : [];
  return <div style={{
    margin: '1.5rem 0'
  }}>
      <div style={{
    display: 'flex',
    alignItems: 'baseline',
    flexWrap: 'wrap',
    gap: '0.5rem',
    marginBottom: '0.25rem'
  }}>
        <strong>{label}</strong>
        <span style={{
    fontSize: '0.7rem',
    fontWeight: 600,
    textTransform: 'uppercase',
    letterSpacing: '0.04em',
    color: required ? '#6241f5' : '#6b7280'
  }}>
          {required ? 'Required' : 'Optional'}
        </span>
      </div>

      <div>{children}</div>

      {diType || patterns.length > 0 ? <p style={{
    fontSize: '0.85rem',
    color: '#6b7280',
    marginBottom: 0
  }}>
          {diType ? <>
              See the <a href={`/references/${diType}`}>{diType}</a> reference.{' '}
            </> : null}
          {patterns.length > 0 ? <>
              Accepts a <a href={`/documentation/placeholders-and-patterns/patterns#${patterns[0]}`}>pattern</a>.
            </> : null}
        </p> : null}
    </div>;
};

Takes a piece of structured data, such as an object or a list, and turns it into a single piece of text in the format you choose. Use this when a system you send data to expects one ready-made string instead of separate fields, for example a JSON body for an API, an XML document, or a YAML file. You pick the formatter, and this mapper hands your data to it and returns the formatted text. If you already know which format you need, the dedicated mappers (Format to JSON, Format to XML, and so on) are quicker to set up; reach for this one when you want to choose the formatter yourself or keep it configurable.

This documentation describes: [Schema](/schemas/mapper/serialize)

## Fields

<FormField property="serializer" label="Formatter" required diType="serializer">
  The formatter that decides which output format your data is converted into, such as JSON, XML, YAML, or form URL encoded. Whatever this formatter produces becomes the resulting text.
</FormField>

## Sample data

This example uses the JSON formatter with pretty printing turned on, so the chosen object comes back as nicely indented JSON text.

| Field     | Value                                |
| --------- | ------------------------------------ |
| Formatter | JSON formatter, Pretty print enabled |

Input:

```json theme={null}
{
    "product": {
        "sku": "SCARF-01",
        "name": "Wool scarf",
        "price": 24.95
    }
}
```

Output:

```json theme={null}
{
    "product": "{\n    \"sku\": \"SCARF-01\",\n    \"name\": \"Wool scarf\",\n    \"price\": 24.95\n}"
}
```

```json Configuration theme={null}
{
  "prototype": "serialize",
  "parameters": {
    "serializer": {
      "prototype": "json",
      "parameters": { "flags": [128] }
    }
  }
}
```
