Need to remove the "bad characters" from the start of a JSON output from GPT

When I ask any of the popular GPT modules (ChatGPT, Claude, or Perplexity) to return data in JSON format it starts the response with ‘’‘json and ends with ‘’’. I have tried text parsing to remove it, but it does not work.

You can see from the attachments how I have the text pattern setup using a variable and what the output is - it doesn’t seem to do anything.


Welcome to the Make community!

You can use the built-in function replace to remove the Markdown codefence from your output:

{{ replace(1.result; "/(^```.+\n|\n```$)/g"; emptystring) }}

(paste this into your field and remap the variable)

For more information, see the replace function documentation in the Help Center.

Hope this helps! Let me know if there are any further questions or issues.

@samliew

P.S.: Investing some effort into the Make Academy will save you lots of time and frustration using Make.

I appreciate the help, I get the following error:

Failed to map ‘value’: Function ‘replace’ finished with error! Invalid regular expression: /^.+\n|\n$)/g: Unmatched ‘)’

Whoops, missed a bracket. edited.