// n8n integration
This operation is available on both n8n Cloud and self-hosted n8n and requires the CustomJS community package. It ships with the next release of the @custom-js/n8n-nodes-pdf-toolkit-v2 package, available from version 0.12.0. See Installation.
The AI JSON Parser operation turns messy AI model output into clean, structured JSON. It fixes exactly the cases where n8n's built-in JSON parsing throws an error:
True, False, and None instead of true, false, and nullJSON.parseInstead of writing a fragile Code node with regex cleanup, add this operation between your AI node and the rest of your workflow. You can find the same cleanup patterns for other platforms in our data cleanup snippets.
The operation lives in the CustomJS (PDF & File Toolkit) node:
DataAI JSON Parser| Parameter | Description | Required |
|---|---|---|
| JSON Text | Raw text that should contain JSON, e.g. an AI model answer | Yes |
| Strict Mode | Strict mode: no content repairs. Only fence removal and block extraction are applied, the content itself is never modified | No (default: off) |
Input (typical AI Agent output):
Sure! Here is the extracted data:
```json
{
"name": "John Doe",
"active": True,
"score": 87.5,
}
```
Let me know if you need anything else.
Output:
{
"result": {
"name": "John Doe",
"active": true,
"score": 87.5
},
"wasRepaired": true,
"notes": [
"Removed markdown code fences",
"Extracted JSON block from surrounding text",
"Repaired common issues (smart quotes, trailing commas, Python/JS literals)"
]
}
| Field | Description |
|---|---|
| result | The parsed JSON value, ready to use in downstream nodes |
| wasRepaired | true if any cleanup or repair was applied, false if the input parsed as-is |
| notes | A list of the cleanup steps that were applied, useful for debugging |
If the text cannot be parsed even after cleanup, the node throws a clear error so you can catch it with n8n's error handling.