ModelWorks logoModelWorks
JSON TransformString

trimEnd

Remove trailing whitespace from a string

trimEnd

Removes trailing whitespace from a string. Leading whitespace is preserved.

Options

This operation takes no options; pass an empty object or omit options entirely.

Example

Input

JSON
"   hello   "

Operation

JSON
{ "type": "trimEnd" }

Output

JSON
"   hello"

In a Circuit Step

JSON
{
  "name": "trim_trailing_newline",
  "description": "Strip the trailing newline from a fetched response body",
  "function": "circuit.core.transform.json",
  "input": {
    "source": "${{ fetch_response.output.text_body }}",
    "operations": [
      { "type": "trimEnd" }
    ]
  },
  "outputs": [
    {
      "name": "body_without_trailing_ws",
      "description": "Response body with trailing whitespace removed",
      "value": "${{ trim_trailing_newline.output.transformed_result }}"
    }
  ]
}

Notes & gotchas

  • Errors with trimEnd: expected string if the input is not a string.
  • "Whitespace" follows Rust's Unicode-aware definition.
  • Use trim to strip both ends or trimStart for the leading side.
On this page

On this page