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

> Converts a data object or array into a YAML formatted string.

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>;
};

Turns a piece of structured data, such as an object or a list, into a single YAML text string. Use this when a system or file you produce expects YAML, a plain-text format that lays out fields one per line. There is nothing to configure: hand it your data and it returns the YAML text.

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

## Sample data

This example formats one object into YAML. Each field becomes its own line, and the price keeps its number form.

Input:

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

Output:

```json theme={null}
{
    "product": "sku: SCARF-01\nname: 'Wool scarf'\nprice: 24.95\n"
}
```

```json Configuration theme={null}
{
  "prototype": "serialize-yaml",
  "parameters": {}
}
```
