Power Query can connect to a JSON file or a JSON API response and turn its nested structure into a flat table you can load into Excel or Power BI. The shortcut is to use the connector for a URL or file, then use the expand buttons and a few list functions to drill into the data. JSON has no fixed shape, so most of the work is telling Power Query which records you want and how deep to unpack them.

What You'll Need

  • Excel (Data > Get Data) or Power BI Desktop, with the Power Query Editor available.
  • A JSON source: a local .json file, a folder of them, or a web endpoint URL that returns JSON.
  • A rough idea of the structure - open the file in a text editor first and note the outer key names and where the array of records sits.
  • For web URLs, the API may need an API key, a token, or a specific Accept header. Check the provider's documentation before you start.

Menu labels in Power Query can differ slightly between Excel versions, Power BI, and operating systems, so if a button is not exactly where described, look for the nearest equivalent in the same ribbon tab or right-click menu.

Step-by-Step

  1. Inspect the JSON first. Open the file in Notepad or any text editor. Find the wrapper - typically a top-level object with a key like data, results, or items - holding a square-bracket array of records. Knowing this saves you guesswork later.
  2. Start the import. In Excel go to Data > Get Data > From File > From JSON. For a web API use Data > Get Data > From Other Sources > From Web. In Power BI Desktop the same options live under Home > Get Data.
  3. Authenticate if prompted. For Web, choose the authentication method the API documents (often Anonymous for open endpoints, or an API key entered as a header or query parameter). If you are unsure, the provider's docs will say which method they expect.
  4. Look at the Navigator window. Power Query shows a preview with a list of possible tables on the left. Click through them. If one looks right, click Transform Data rather than Load, so you can clean the shape before it hits a worksheet.
  5. Convert to a table or expand the record. If the query returns a single record, click the Record link in the value cell or use the expand icon in the column header. If it returns a list, click List to see entries, then use Into Table to turn the list into rows.
  6. Expand nested columns. Columns containing [Record] or [List] show a small expand icon at the right of the header. Click it, tick the fields you want, and untick Use original column name as prefix if you prefer cleaner headers. Repeat for each level of nesting, one level at a time.
  7. Expand lists inside rows carefully. Expanding a list column gives you an option to expand to new rows or to values only. If the list holds multiple records per parent row, choose Expand to New Rows so each record becomes its own row and the parent fields repeat.
  8. Set data types. JSON imports often land as any or text. Click the type icon in each column header and set Whole Number, Decimal Number, Date, or Text as appropriate. Set types after expanding, because expansion can reset them.
  9. Remove what you do not need. Right-click columns you will not use and choose Remove. Also check for duplicate rows if the source repeats records, using Remove Rows > Remove Duplicates on a unique key column.
  10. Rename and reorder columns to readable headers, and drag them into a sensible order. This is cosmetic but makes the loaded table usable.
  11. Check the Applied Steps. The right-hand pane lists every transformation. Click back through the steps to confirm each one produced what you expected - this is the fastest way to find where a query went wrong.
  12. Load the result. Click Close & Load (or Close & Load To... to choose a table, pivot, or connection only). To refresh later, use Data > Refresh All in Excel, or Refresh in Power BI.

Common Mistakes

  • Expanding before choosing the right level. If you expand a top-level record that only contains metadata, you end up with one useless row. Navigate to the array first, then expand.
  • Loading without a preview check. Clicking Load on the Navigator preview without examining the shape often produces a one-cell table or a column of [Record] values.
  • Types set too early. Setting a column to a number, then expanding it, can produce errors. Set types as the final transformation.
  • Ignoring nulls. JSON often omits keys entirely. Missing fields come through as null, and math on nulls returns errors until you replace them with a default using Replace Values.
  • Hard-coding a stale URL or file path. If the file moves or the API endpoint changes, the query breaks. Use parameters for paths and URLs so they are easy to update.
  • Assuming paginated APIs return everything. Many endpoints return one page of results and a cursor or next-page URL. Power Query will not follow that automatically; you need to generate a list of pages and combine them.

Tips

  • Work one level of nesting at a time and rename each step in the Applied Steps pane so you can find and undo a single change.
  • Use Table.ExpandListColumn behaviour via the expand icon rather than writing M by hand if you are new to the language; the generated code is a good learning reference.
  • If a nested field is sometimes an object and sometimes an array, expand it once, check the result, and handle the odd rows with a conditional column or by filtering them out.
  • For folders of JSON files, use Get Data > From Folder, then expand Content and combine files so new files are picked up on refresh.
  • Keep a sample of the source JSON saved. When the API changes shape, comparing old to new tells you exactly which step to fix.

Troubleshooting

The preview is empty or shows a single row. You are probably looking at the wrong table in Navigator, or you selected the top-level record. Go back and choose Transform Data, then use the Record or List links to step inside.

Every value says Error. Check the error message on the cell. Common causes are a changed data type or a missing field after expansion. Remove the type step, look at the raw values, and reapply the type at the end of the query.

The refresh fails but the first load worked. Usually the source moved, the API key expired, or the endpoint returned an error page instead of JSON. Test the URL in a browser or a tool like Postman and check whether the response is still JSON.

Columns are duplicated or names look wrong. During expansion, the prefix option may have been left on, or the parent row repeated. Rename the columns and check whether Expand to New Rows created extra rows you did not expect.

Dates import as text. The source may use a format your region does not recognise. Use Change Type with Locale to specify the source format rather than the local one.

If that did not work, create a fresh query from the same source and compare its shape to your broken one, step by step. If the source itself has changed, you will need to rebuild the expansion steps rather than patch them.

Frequently Asked Questions

Can Power Query read a JSON file directly from disk?

Yes. Use From File > From JSON and browse to the file. The path is stored in the query, so refresh works as long as the file stays where it was.

Does Power Query handle deeply nested JSON?

Yes, but you expand one level at a time. Each expansion reveals the next layer, so keep clicking the expand icon until the structure is flat.

Can I combine several JSON files into one table?

Yes. Point From Folder at the directory, expand the Content column, then combine the files. New files added to the folder appear on refresh.

Why does my JSON API only return part of the data?

The endpoint is likely paginated. Power Query does not follow next-page links automatically, so you need to build a list of page requests and combine the results.

Do I need to know M code?

No for most imports. The ribbon and right-click menus generate the M behind the scenes; you only need to read or edit it for unusual shapes or pagination.

Will refreshing break if the JSON structure changes?

Often yes. If a key is renamed or moved, the expansion step fails. Rebuild that step against the new structure and check the remaining steps still reference the right columns.