How to use Parse JSON in Power Automate
Add a Parse JSON action, put your JSON text in Content, and select Generate from sample to build the schema. Later steps then show each JSON value as dynamic content you can pick.
What does the Parse JSON action do?
Parse JSON reads text that holds JSON and splits it into named fields. Without it, a flow sees one long block of text. With it, you pick values such as name or total from the dynamic content list.
Use it after an HTTP call, a webhook trigger, or any action that returns JSON text. SharePoint actions such as Get items already return fields, so you do not need Parse JSON for them.
How do you add Parse JSON to a flow?
- Select New step, then search for Parse JSON under Data Operation.
- In Content, select the dynamic content that holds the JSON, such as Body from the HTTP action.
- Select Generate from sample.
- Paste one example of the JSON, then select Done.
- Check the schema box. It now lists each field and its type.
- Use the new dynamic content in later steps.
How do you get a good sample for Generate from sample?
Copy a real response from the flow run history. Open the run, open the action that returned the JSON, and copy the Body from the output.
The generator builds a strict schema from your sample. If every field has a value, it treats every field as required and non-null. Add a second record to the sample that leaves optional fields empty, so the generator can see which fields may be null.
Why does Parse JSON fail with Invalid type?
The schema says a field has one type, and the data has another. A common message is that the action expected Integer but got Null. The real data has a null where your sample had a number.
To fix it, open the schema and change the type of that field to a list of types, such as ["integer", "null"]. The same pattern works for string, number, and boolean. Our guide on Invalid type, expected String but got Null covers the string case.
Why does Parse JSON say a required property is missing?
Generate from sample adds every field it sees to the required list in the schema. If a later response leaves out one of those fields, the action fails, even if the field would be null.
Open the schema, find the required list, and delete the names of fields that are sometimes missing. Save the flow and run it again with a response that leaves the field out.
Should you use Parse JSON or an expression?
Use an expression when you need one value from one response. For example, body('HTTP')?['name'] returns the name field. The question mark keeps the flow from failing when a field is missing.
Use Parse JSON when you need many fields, or when other people will edit the flow. The dynamic content list is easier to read than long expressions. If a template expression fails, see InvalidTemplate errors.
What if the JSON is a list?
If the response starts with a square bracket, it is a list. Generate from sample builds an array schema. Parse JSON then returns a list, and you loop over it with Apply to each.
If the list is large, filter it first with Filter array so the loop runs fewer times.
FAQ
Do I need Parse JSON for SharePoint Get items?
No. Get items already returns fields you can pick.
How do I allow a null value in the schema?
Change the field type to a list, such as ["string", "null"].
Sources
- Parse JSON Action
- How to solve the JSON Invalid type error in Power Automate?
- Use the Data operation actions in Power Automate