Actions20
- Assistant Actions
- Embedding Actions
- File Actions
- Report Actions
- Text Actions
- Thread Actions
Text → Parse JSON
AI-generatedOverview
This node provides functionality to parse a JSON string input into a JavaScript object with robust error handling. It is especially useful when working with JSON data that might be malformed or contain syntax errors. The node can optionally leverage an AI model (from OpenAI) to automatically fix JSON syntax errors before parsing, improving reliability and reducing manual correction efforts.
Typical use cases include:
- Parsing JSON responses from APIs or external sources that may occasionally have formatting issues.
- Automatically correcting and parsing user-generated JSON input.
- Integrating with workflows where JSON data integrity is critical but not guaranteed.
For example, if you receive a JSON string with missing commas or quotes, enabling the AI fix option allows the node to attempt automatic correction using an OpenAI model before parsing it into an object.
Properties
| Name | Meaning |
|---|---|
| Authentication | Choose which API credentials to use: - OpenAI Analytics API - OpenAI API |
| JSON Input | The JSON string to parse. This is the raw JSON text input that the node will process. |
| Use AI Fix | Whether to use an OpenAI model to fix JSON syntax errors before parsing. |
| OpenAI Model | The OpenAI model to use for fixing JSON syntax errors (shown only if "Use AI Fix" is enabled). |
Output
The node outputs the parsed JSON as a standard JavaScript object in the json field of the output item.
- If parsing succeeds without errors, the output contains the parsed object.
- If parsing fails and "Use AI Fix" is enabled, the node attempts to correct the JSON using the selected OpenAI model and then parses it.
- If parsing ultimately fails and the node is configured to continue on failure, the output will contain an error message under
json.error.
No binary data output is produced by this operation.
Dependencies
- Requires valid API credentials for either the OpenAI Analytics API or the OpenAI API.
- The node uses the OpenAI client library to interact with OpenAI models for fixing JSON syntax errors.
- Proper configuration of these credentials in n8n is necessary for the AI fix feature to work.
Troubleshooting
Common Issues:
- Invalid or malformed JSON input that cannot be parsed.
- Missing or incorrect API credentials causing authentication failures.
- Network or API errors when calling OpenAI services for AI-based fixes.
Error Messages:
"Unsupported resource: ..."— indicates the node was called with a resource other than "text".- JSON parsing errors — if AI fix is disabled or fails, the node throws an error indicating invalid JSON.
- Credential loading errors — ensure API keys are correctly set up in n8n credentials.
Resolutions:
- Verify the JSON input string is properly formatted or enable "Use AI Fix" to allow automatic correction.
- Check and update API credentials in n8n settings.
- Ensure network connectivity to OpenAI endpoints.
Links and References
Note: This summary is based solely on static analysis of the provided source code and property definitions. Runtime behavior may depend on actual API responses and environment configurations.