---
title: OBJECTS_TO_CSV
url: https://www.tines.com/docs/formulas/functions/objects-to-csv/
kind: formula-function
---

*[tines.com](https://www.tines.com/llms.txt) › [Docs](https://www.tines.com/llms.txt) › [Formulas](https://www.tines.com/llm/docs/formulas.md) › [Functions](https://www.tines.com/llm/docs/formulas/functions.md)*

# OBJECTS_TO_CSV

*[View on tines.com](https://www.tines.com/docs/formulas/functions/objects-to-csv/)*

Parses an array of objects with the same keys into CSV-formatted text. Headers are optional, if none are provided the keys of the first object are used.

**Categories:** Data Parsing/Conversion

## Syntax

```
OBJECTS_TO_CSV(objects, headers)
```

## Examples

### Example 1

Input:

```json
{
  "my_action": {
    "objects": [
      {
        "age": 45,
        "city": "Melbourne",
        "name": "John Smith"
      },
      {
        "age": 32,
        "city": "Sydney",
        "name": "Jane Doe"
      },
      {
        "age": 27,
        "city": "Brisbane",
        "name": "Bob Jones"
      }
    ]
  }
}
```

Formula:

```
OBJECTS_TO_CSV(my_action.objects)
```

Output:

```json
"name, age, city\nJohn Smith, 45, Melbourne\nJane Doe, 32, Sydney\nBob Jones, 27, Brisbane\n"
```

### Example 2

Input:

```json
{
  "my_action": {
    "objects": [
      {
        "age": 45,
        "city": "Melbourne",
        "name": "John Smith"
      },
      {
        "age": 32,
        "city": "Sydney",
        "name": "Jane Doe",
        "address": "123 Main St"
      },
      {
        "age": 27,
        "city": "Brisbane",
        "name": "Bob Jones"
      }
    ]
  }
}
```

Formula:

```
OBJECTS_TO_CSV(my_action.objects, ["name", "age", "address"])
```

Output:

```json
"name, age, address\nJohn Smith, 45,\nJane Doe, 32, 123 Main St\nBob Jones, 27,\n"
```

## Sample actions

```json
{
  "standardLibVersion": "13",
  "actionRuntimeVersion": "2",
  "agents": [
    {
      "disabled": false,
      "name": "My Action",
      "description": "",
      "options": {
        "mode": "message_only",
        "loop": false,
        "payload": {
          "objects": [
            {
              "name": "John Smith",
              "age": 45,
              "address": "Melbourne"
            },
            {
              "name": "Jane Doe",
              "age": 32,
              "address": "Sydney"
            },
            {
              "name": "Bob Jones",
              "age": 27,
              "city": "Brisbane"
            }
          ]
        }
      },
      "position": {
        "x": 3120,
        "y": 2055
      },
      "type": "eventTransformation",
      "timeSavedUnit": "minutes",
      "timeSavedValue": 0,
      "monitorAllEvents": false,
      "monitorFailures": false,
      "monitorNoEventsEmitted": null,
      "form": null
    },
    {
      "disabled": false,
      "name": "OBJECTS_TO_CSV",
      "description": "",
      "options": {
        "mode": "message_only",
        "loop": false,
        "payload": {
          "objects_to_csv": "=OBJECTS_TO_CSV(my_action.objects)"
        }
      },
      "position": {
        "x": 3120,
        "y": 2145
      },
      "type": "eventTransformation",
      "timeSavedUnit": "minutes",
      "timeSavedValue": 0,
      "monitorAllEvents": false,
      "monitorFailures": false,
      "monitorNoEventsEmitted": null,
      "form": null
    }
  ],
  "links": [
    {
      "sourceIdentifier": 0,
      "receiverIdentifier": 1
    }
  ],
  "diagramNotes": []
}
```
