Skip to content

JSON: Validate

Checks whether a given string is valid JSON. Returns a boolean indicating validity and an error message string describing why validation failed, or empty when valid.
Preview

Usage

Use this node when you need to verify that text produced by an upstream step is well-formed JSON before attempting to parse or consume it. Commonly placed after a model or tool that outputs JSON-like text to gate downstream processing.

Inputs

FieldRequiredTypeDescriptionExample
json_stringTrueSTRINGThe text to validate as JSON. Must be a standard-compliant JSON string (double-quoted keys/strings, no comments or trailing commas).{"user": {"id": 123, "name": "Ada"}, "items": [1, 2, 3]}

Outputs

FieldTypeDescriptionExample
is_validBOOLEANTrue if the input is valid JSON, otherwise False.true
error_messageSTRINGAn error description if validation fails. Empty string when the JSON is valid.Expecting property name enclosed in double quotes: line 1 column 3 (char 2)

Important Notes

  • Validation only: This node does not return parsed data; it only checks validity.
  • Strict JSON: Only standard JSON is accepted (no comments, single quotes, or trailing commas).
  • Input type matters: Non-string inputs (e.g., None) will produce an 'Unexpected error' message; ensure you pass a string.
  • Empty output on success: The error_message output is an empty string when the JSON is valid.

Troubleshooting

  • Invalid due to quotes: Use double quotes for keys and string values (e.g., {"key": "value"}), not single quotes.
  • Trailing comma error: Remove any trailing commas in objects or arrays.
  • Escape characters: Ensure special characters inside strings are properly escaped (e.g., newline as \n).
  • Non-string input: If you see 'Unexpected error', verify the input is a STRING and not null or another type.
  • Large payloads: If validation intermittently fails, check for truncated input from upstream nodes and ensure the full JSON string is passed.