Skip to content

JSON: To String

Converts any input data into a JSON-formatted string. Supports pretty (indented) or compact formatting and safely handles common Python types, converting non-JSON-serializable values to strings. Returns a single STRING output containing the serialized JSON.
Preview

Usage

Use this node when you need to serialize data for logging, storage, display, or passing into downstream nodes or external services that expect JSON text. Common in workflows that transform structured data (dicts/lists) into a transportable string or when preparing payloads for API requests.

Inputs

FieldRequiredTypeDescriptionExample
inputTrueWILDCARDThe data to convert to a JSON string. Accepts dictionaries, lists, numbers, booleans, None, strings, and other types (which will be stringified).{'user': {'id': 123, 'name': 'Ava'}, 'items': [{'sku': 'A-100', 'qty': 2}]}
prettyTrueBOOLEANIf true, output is indented for readability; if false, output is compact with no extra whitespace.True

Outputs

FieldTypeDescriptionExample
json_stringSTRINGThe JSON-formatted string representation of the input data.{ "user": { "id": 123, "name": "Ava" }, "items": [ { "sku": "A-100", "qty": 2 } ] }

Important Notes

  • Strings as input are converted to JSON string literals (they will be wrapped in quotes and may contain escaped characters), not passed through verbatim.
  • Non-JSON-serializable objects are converted to their string representation.
  • None becomes null; booleans are rendered as true/false; Unicode is preserved (no ASCII escaping).
  • Pretty formatting adds indentation; compact formatting uses minimal separators.
  • On serialization errors, the node falls back to returning str(input), which may not be valid JSON.

Troubleshooting

  • Output shows extra quotes or escaped characters: Your input was a plain string; the node emits a JSON string literal. If you need the raw string, avoid converting to JSON or parse downstream accordingly.
  • Output is 'null' or empty-like: The input might have been None or an empty/whitespace string parsed as None upstream.
  • Output is not valid JSON: The node fell back to str(input) due to a serialization error. Check for circular references or unsupported objects and consider converting them to dict/list or primitives before serialization.
  • Unexpected large file size: Disable pretty formatting (set pretty to false) to produce a compact JSON string.