How to Convert JSON to XML in Power Automate

Cloudmersive
4 min readNov 8, 2024

--

JSON is the default format for structuring data in Power Automate. If we’re integrating XML files in Power Automate at any point & attempting to use that data as dynamic content, we’ll greatly benefit from having a consistent, easy-to-use XML to JSON conversion service in our arsenal.

In this article, we’ll walk through a basic flow that uses a Cloudmersive Document Conversion action to convert an XML file to JSON. We’ll end up with a JSON object we can structure with Data Operation actions and utilize downstream in our flow.

We’ll build a manually triggered instant cloud flow in this context so we can more easily control our inputs in a quick test scenario.

We’ll start by pulling an XML file from our file system using a Get file content action. In my example, I’ll be using the OneDrive for Business iteration of this action, and I’ll be retrieving an XML file which contains “user information” from some external application.

Next, we’ll add a new action and search for Cloudmersive connectors. We’re looking for the Cloudmersive Document Conversion connector, which has a green logo.

To view the entire actions list, we’ll click “See more”. From there, we’ll search for an action titled Convert XML to JSON conversion.

After selecting this action, we’ll need to create our Cloudmersive Document Conversion connection. Since this is a third-party service, we’ll need a premium Power Automate license to do so; as long as we have that, we can then use the connector for free with a free Cloudmersive API key. Free API keys allow a monthly limit of 800 API calls with zero additional commitments.

When our connection is created and authorized, we’ll add our XML file content + a file name in our two request parameters (note that we don’t need the real file name for this operation; the endpoint simply requires any name before performing the conversion operation).

Now that we’ve converted our XML data to JSON, we’ll walk through one quick example of how to prepare our data for downstream use. We’ll use the Compose action from the Data Operation connector to format our JSON object without the XML versioning declaration. To do so, we’ll pass response content labeled Body (which contains the full JSON object) to the Compose action.

Now we’ll save and test our flow to review our output.

After running our flow, we’ll find our full JSON object in the Body output of the Convert XML to JSON action.

In the output of our Compose action, we’ll find the Users object separated from the ?xml object.

It isn’t strictly necessary to process our data this way, but it serves to show one example of how Power Automate is prepared to re-structure and optimize JSON data for downstream use.

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.