Skip to content

JSON: Validate

Checks whether a given text is valid JSON. Returns a boolean indicating validity and an accompanying error message if invalid. Does not modify or parse the input beyond validation.
Preview

Usage

Use this node when you need to verify that a string is valid JSON before parsing it or passing it into downstream steps that expect structured data. Typical workflow: receive or construct a JSON string, validate with this node, then conditionally branch—parse or proceed if valid, or log/handle the error if invalid.

Inputs

FieldRequiredTypeDescriptionExample
json_stringTrueSTRINGThe text to validate as JSON. Supports multiline strings. The node checks only JSON syntax validity.{"name": "Salt", "count": 3}

Outputs

FieldTypeDescriptionExample
is_validBOOLEANTrue if the input is syntactically valid JSON; otherwise False.True
error_messageSTRINGError message describing why validation failed. Empty string when is_valid is True.Expecting property name enclosed in double quotes: line 1 column 2 (char 1)

Important Notes

  • Validation scope: This node validates JSON syntax only; it does not validate against a schema or enforce specific fields.
  • Empty success message: When the JSON is valid, the error_message output is an empty string.
  • Input type: The input must be a STRING; other types should be converted to string JSON first.
  • Multiline support: Multiline JSON strings are accepted.
  • Common pitfalls: Single quotes, trailing commas, and unescaped characters will cause validation to fail.

Troubleshooting

  • Always invalid with 'Expecting value': Ensure the input isn't empty or whitespace-only and that it starts with a valid JSON token (e.g., {, [, ")
  • Using single quotes: Replace single quotes with double quotes for keys and string values to conform to JSON.
  • Trailing commas: Remove any trailing commas in objects or arrays.
  • Encoding issues: If you see an 'Unexpected error', ensure the string is properly encoded (e.g., UTF-8) and characters are correctly escaped.
  • Valid but downstream fails: Being valid JSON doesn't guarantee the structure matches what downstream steps expect (e.g., object vs array). Inspect the parsed structure.