1. Handlebars Helpers
  2. To JSON String

Handlebars Helpers

To JSON String

Serializes values to JSON strings during Handlebars substitution. Useful for API payloads, prompts, logs, and passing structured data between tasks.

Uses

You can use this helper to convert an object, value, or array to a JSON string.
This is helpful when you want to pass some data to an LLM task as a JSON. You can use this inline to convert the data to a JSON string directly in prompts.

TIP

You could use the JSONata hashtag helper to convert the other way, from a JSON string back to an object.

Usage

Helper name : to_json_string

Parameter Description
1 object / value / array to convert to JSON string
2 pretty print, to make the output easier to read

Examples

Example use in task:

loading...

Substituted definition

loading...

Example of pretty print

loading...

OUTPUT

{ "number": 1, "string": "string", "boolean": true, "array": [ 1, 2, 3 ], "obj": { "a": 1 } }