Skip to main content

Notifications

Community site session details

Community site session details

Session Id : XSOrqgcc4UXKynfCArm8rg

Convert HTML Table to JSON array

ManishSolanki Profile Picture Posted 03 Jun 2024 by ManishSolanki 15,085 Super User 2025 Season 1

This AI prompt can be used for reading an html table from an email body & convert it to JSON array. The array can further be used to store date in different data source like in online excel file, SharePoint, Dataverse etc.

 

Create Prompt:

Select "AI hub" from left navigation & click "AI prompts" tile:

ManishSolanki_0-1717422443060.png

 

Next, click "Create text with GPT using a prompt" tile to create a new prompt:

ManishSolanki_1-1717422510256.png

 

Enter the name as 'Convert HTML Table to JSON array' in "Prompt details" section.

 

Expand 'Input' section and create 3 input parameters.

  • HTML Table - This parameter will store the value of HTML table
  • ExcludeColumns - This parameter will store the comma separated list of columns that needs to be excluded from the output JSON array.
  • OutputStructure - This parameter defines the output properties of the output JSON array.

ManishSolanki_2-1717423014828.png

Select 'JSON (preview)' in "Output" section:

ManishSolanki_3-1717423301118.png

 

Choose 'GPT (preview)' from the "Model" dropdown:

ManishSolanki_4-1717423420748.png

 

Enter the below text in the "Prompt" (left side):

Create a valid JSON array of objects to list columns from given HTML table:

Exclude  property in each JSON object.
Provide valid JSON response that strictly comply with below structure:

Click 'Insert' button and add the parameter in the correct location:

ManishSolanki_5-1717424306827.png

Similarly, add other parameters in the prompt text:

ManishSolanki_6-1717424414882.png

Test Prompt

Enter the sample values in the input parameters to test the custom prompt:

 

HTML Table:

<table> <tr> <th>Company</th> <th>Contact</th> <th>Country</th> </tr> <tr> <td>Alfreds Futterkiste</td> <td>Maria Anders</td> <td>Germany</td> </tr> <tr> <td>Centro comercial Moctezuma</td> <td>Francisco Chang</td> <td>Mexico</td> </tr> </table>

 

ExcludeColumns:

Contact

 

OutputStructure:

Sample data: [{"Company":"String","Contact":"String","Country":"String"}]

 

Click 'Test prompt' button to get the response:

ManishSolanki_7-1717425131344.png

 

 

Output Response:

ManishSolanki_0-1717428046848.png
[
  {
    "Company": "Alfreds Futterkiste",
    "Country": "Germany"
  },
  {
    "Company": "Centro comercial Moctezuma",
    "Country": "Mexico"
  }
]

 

 

Check out my blog to see it in action for extracting html table in email body to JSON array:

Custom AI Prompt to convert html table to JSON array (manish-solanki.com)

 

 

 

 

 

 

 

 

Categories:

AI Builder Power Automate

Comments