ModelWorks logoModelWorks
JSON TransformString

split

Split a string into an array of substrings

split

Splits a string on separator, returning an array of substring elements. The optional limit caps the number of resulting parts; the final part contains the unsplit remainder.

Options

OptionTypeRequiredDefaultDescription
separatorstringYesSubstring used as the split delimiter.
limitintegerNoMaximum number of parts. The last part holds the unsplit remainder.

Example

Input

JSON
"a,b,c,d"

Operation (no limit)

JSON
{ "type": "split", "options": { "separator": "," } }

Output

JSON
["a", "b", "c", "d"]

Operation (with limit)

JSON
{ "type": "split", "options": { "separator": ",", "limit": 2 } }

Output

JSON
["a", "b,c,d"]

In a Circuit Step

JSON
{
  "name": "split_csv_tags",
  "description": "Split a comma-separated tag string into an array",
  "function": "circuit.core.transform.json",
  "input": {
    "source": "${{ input.tags_csv }}",
    "operations": [
      { "type": "split", "options": { "separator": "," } }
    ]
  },
  "outputs": [
    {
      "name": "tag_list",
      "description": "Array of tag strings",
      "value": "${{ split_csv_tags.output.transformed_result }}"
    }
  ]
}

Notes & gotchas

  • Errors with split: expected string if the input is not a string.
  • separator is treated as a literal substring, not a regex.
  • An empty separator will split between every character in Rust's splitn semantics — pass it deliberately if that's what you want.
  • limit: 0 produces an empty array; limit: 1 produces the original string as a single-element array.
On this page

On this page