⚡ Power Automate - Efficient CSV to JSON
Recently had to convert a CSV file to JSON in a Power Automate Flow and found that all existing articles on this are using inefficient loops
I recently was looking at converting CSV content to JSON in a Power Automate Flow in order to be able to work with it.
Existing articles on this topic seem to all be using inefficient loops so I decided to provide an example of an efficient Data Operations implementation.
The overall flow looks like this:
High level overview:
- HTTP call gets the CSV file content
- Compose to split the lines into an array
- Select to split the rows into an array
- Select to map the rows to objects
- Filter as an example on how to further process the objects
Split Lines
Type: Compose
Takes a single CSV string and splits it by new-line into an array of strings
skip(split(trim(body('HTTP')), decodeUriComponent('%0D%0A')), 1)
skip(1)
to drop the header
trim
to get rid of empty lines
decodeUriComponent('%0D%0A')
represents the new-line character
Split Rows
Type: Select
Takes an array of strings and splits them by comma into an array of arrays of strings.
split(item(), ',')
Map to Object
Type: Select
We unwrap each nested array into actual objects
For each column, assign item()?[0]
with the corresponding index
The final output will be an array of objects:
[
{
"DateModified": "3/25/2025",
...
},
{
...
}
]
Conclusion
This is an efficient way to convert CSV to JSON in Power Automate Flow.
The key is to use Data Operations instead of Control Loops.
Looping over even small collections will take seconds as opposed to near-instant data operations.
For more see Dataverse Performance - Flow Iteration