Torq’s String utility steps let you manipulate and transform text values easily within workflows. These steps help standardize, clean, or format data to match automation requirements.
Escaping and template rendering
Escape JSON String
Escapes special characters in a string so it can be safely embedded inside a JSON value. This prevents malformed JSON when your text includes quotes, backslashes, tabs, or newlines.
What gets escaped
">\\"\\>\\\\Newlines >
\\nTabs >
\\tOther control characters that can break JSON payloads
Where this helps most
Building JSON bodies for HTTP/API steps when input comes from users, alerts, or logs.
Posting text into Slack or Jira fields that are sent as JSON.
Storing multi-line strings inside JSON objects.
Preparing data for downstream encoding steps (e.g., JSON > YAML, Base64).
Input
The string which needs "escaping" line 2 here
Output
The string which needs \\"escaping\\"\\nline 2 here
Render Template
Renders a template string using variable placeholders. This is useful for dynamically generating messages, filenames, or payloads.
Template
Hello, this is my {{`{{.name}}`}}Variables
{ "name": "Bob" }Output
Hello, this is my Bob
Text case and normalization
Convert String to Lowercase
Converts all characters in the input string to lowercase.
Input
Convert This String to Lowercase
Output
convert this string to lowercase
Convert String to Title Case
Converts the first character of each word in the string to uppercase.
Input
convert this string to title case
Output
Convert This String To Title Case
Convert String to Uppercase
Converts all characters in the input string to uppercase.
Input
Convert this string to uppercase
Output
CONVERT THIS STRING TO UPPERCASE
Security and safe sharing
Defang or Refang Entity
Defangs or refangs a given IP, URL, or email address. This transformation replaces or restores the following substrings: ., @, and http.
Input
nora.singh@twistt.io
Output
nora[.]singh[@]twistt[.]io
Replace, split, and transform text
Replace Substring in Text
Replaces a specified substring with another string. You can define how many instances to replace (default: all).
Input
Like this and like this.
Old text
this
New text
that
Instances
1
Output
Like that and like this.
Split Text
Splits a text string into an array based on the provided separator. The separator text itself is removed from the output.
Input
Let's split this text.
Separator
this
Output
[ "Let's split ", " text." ]
Truncate Text
Limits a string to the number of characters specified.
Input
Truncate this text to 15 characters.
Limit
15
Output
Truncate this t
Fix Unicode Double Quotes
Replaces curly (Unicode) quotation marks (U+201C and U+201D) with standard straight single quote ('). This helps ensure text consistency in data formatting, especially for JSON or API payloads.
Input
“Torq” automations make workflows smarter.
Output
'Torq' automations make workflows smarter.
When the input text contains multiple lines or special characters that may break JSON formatting, use the jsonEscape template to sanitize it before processing. For example, {{ jsonEscape $.input_text.output }}.
Trimming and cleanup
Trim Spaces Before and After String
Removes empty spaces before and after the input string.
Input
Remove the 3 empty spaces before and after this string.
Output
Remove the 3 empty spaces before and after this string.
Trim String Characters
Removes specific characters from the beginning and/or end of a string.
Input
I want to trim the following characters.
Characters
I w.rs
Side to trim
Trim prefix and suffix
Output
ant to trim the following characte
Trim String Prefix
Removes a defined prefix from the string.
Input
prefix_incident_report.json
Prefix
prefix_
Output
incident_report.json
Trim String Suffix
Removes a defined suffix from the string.
Input
incident_report.json
Suffix
.json
Output
incident_report
Use case: Defang Entity
Automatically sanitize suspicious URLs or email addresses from incoming security alerts using the Defang Entity utility, then share the safe version in Slack. This workflow reduces the risk of accidental clicks while preserving the original indicator for investigation.
Receive a suspicious indicator from an alert: Configure the workflow to ingest a security alert that includes an indicator (URL or email) and relevant context such as source, severity, affected user, and timestamp.
Defang the entity using the Defang or Refang Entity utility:
Continue with the next steps: After defanging the indicator, send a Slack message to your security channel (for example,
#sec-ops) that includes the alert context plus both the original and defanged values. Use the defanged indicator for safe sharing in tickets, reports, or threat intel feeds.

