# JSON Escape Action

The **JSON Escape Action** node escapes a JSON payload so it can safely be embedded inside another string, request body, or API call.

It converts special characters (such as line breaks, quotes, and formatting characters) into escaped representations. This is especially useful when JSON must be passed as a string parameter to another system (for example inside another JSON object, XML document, or HTTP request).

#### Input Parameters

**Payload**\
The JSON object to be escaped.

The payload can be provided in multiple ways:

* manually as plain text
* via [{node.result.?}](https://docs.helmut.de/helmut4-releases/helmut4-components/streamdesigner/wildcards/result-or-return-wildcards-2/node-result)
* via [{stream.last\_result}](https://docs.helmut.de/helmut4-releases/helmut4-components/streamdesigner/wildcards/result-or-return-wildcards-2/stream-last_result)
* by reading a file using [{file.content.?}](https://docs.helmut.de/helmut4-releases/helmut4-components/streamdesigner/wildcards/file-related-wildcards-5/file-content)

The input must be **valid JSON**.

<figure><img src="https://content.gitbook.com/content/cJYkTyk9qgh7aCR6dHIm/blobs/3U5L3frKlkrhcsTjAAkH/image.png" alt="" width="351"><figcaption><p>JSON Escape Action</p></figcaption></figure>

#### Output and Wildcards

The escaped JSON string is returned as the node result and can be accessed using:

* [`{stream.last_result}`](https://docs.helmut.de/helmut4-releases/helmut4-components/streamdesigner/wildcards/result-or-return-wildcards-2/stream-last_result)
* [{node.result.?}](https://docs.helmut.de/helmut4-releases/helmut4-components/streamdesigner/wildcards/result-or-return-wildcards-2/node-result)

#### Behavior

* Reads a valid JSON payload
* Escapes special characters (e.g., quotes and line breaks)
* Returns the escaped JSON as a string
* Fails if the provided JSON is invalid

#### Typical Use Cases

* embedding JSON inside another JSON structure
* sending JSON as a parameter in an HTTP request
* integrating with APIs requiring stringified payloads
* passing structured metadata to third-party systems
* preparing payloads for webhooks

#### Example

**Input**

```json
{
  "id": 12345,
  "name": "Sample User"
}
```

**Output**

```json
{\n
  "id": 12345,\n
  "name": "Sample User"\n
}\n
```

The result can now be safely inserted into another string-based payload.

#### Practical Tip

If an API expects JSON but returns errors like *invalid character*, *malformed body*, or *unexpected token*, the problem is often an unescaped JSON string.\
This node is commonly placed before the [HTTP Request Action](https://docs.helmut.de/helmut4-releases/helmut4-components/streamdesigner/nodes/actions/misc-21/http-request-action) when JSON must be nested inside another request body.
