String transform functions

  • Release version: Zurich
  • Updated November 20, 2025
  • 4 minutes to read
  • Summarize
    Summarized using AI
    This content was generated using new OpenAI-powered functionality. Results are provided on an as is basis and are not guaranteed to be accurate or complete.

    Summary of String transform functions

    String transform functions in ServiceNow Zurich release enable you to reformat or perform calculations on String data pills within your flow logic. These functions require String input data pills and return transformed String outputs or related data types. Applying string transform functions to incorrect data types results in no transformation at runtime, returning the original input value instead.

    Show full answer Show less

    Key Features

    • Convert String to Number: Converts a numeric string to a number data type.
    • Contains / Does not Contain: Returns a Boolean indicating whether the input string contains or does not contain a specified sequence of characters.
    • Ends With / Starts With: Returns a Boolean indicating whether the string ends or starts with a specified sequence.
    • First Character / Last Character: Extracts the first or last character from the string.
    • Replace String: Uses JavaScript regular expressions to replace parts of the string with a specified replacement string.
    • Size: Returns the total number of characters in the input string.
    • Split: Splits the string into an array of substrings based on a specified delimiter.
    • Substring: Returns part of the string between specified start and end indices; returns the original string if the start index exceeds the string length.
    • To Lower Case / To Upper Case: Converts the entire string to lowercase or uppercase characters.
    • To Proper Case: Capitalizes the first letter of each word while lowercasing other letters; words are separated by spaces, hyphens, or slashes.
    • Trim: Removes leading and trailing whitespace from the string without affecting internal spaces.

    Practical Use and Examples

    These functions are practical for manipulating string data during flow executions, such as formatting user input, preparing data for integrations, or extracting specific information. For example, you can use the First Character function to set a city code based on a user’s city name or the Trim function to clean whitespace from data returned by external REST calls before saving it to a Configuration Item record.

    Using these functions correctly ensures accurate data transformation and improves automation reliability. Remember to verify that the input data pill is of the String type to avoid runtime issues.

    Use string transform functions to reformat or perform calculations on String data pills.

    String transform functions require a String input data pill. Make sure to use the correct input data pill type when applying string transform functions. If a string transform function is applied to an improper data type, the data is not transformed at runtime and the input value is returned instead. For more information on confirming your flow runtime values, see Test a flow.

    Convert String to Number

    Converts a string into a number.

    Input data pill Output data pill
    String Number - Number converted from a string.
    Figure 1. Example
    • Input: “500”
    • Output: 500

    Contains

    Returns true when the input string contains a given sequence of characters.

    Input data pill Parameters Output data pill
    String Characters to search for. Boolean indicating whether a sequence of characters exists in the input string
    Figure 2. Example
    • Input: Cheese Pizza
    • Parameter: Cheese
    • Output: true

    Does not Contain

    Returns true when the input string does not contain a given sequence of characters.

    Input data pill Parameters Output data pill
    String Characters to search for. Boolean indicating whether a sequence of characters does not exist in the input string
    Figure 3. Example
    • Input: Cheese Pizza
    • Parameter: Joey
    • Output: true

    Ends With

    Returns true when the input string ends with a given sequence of characters.

    Input data pill Parameters Output data pill
    String Characters to search for. Boolean indicating whether the input string ends with the given sequence of characters
    Figure 4. Example
    • Input: Cheese Pizza
    • Parameter: Pizza
    • Output: true

    First Character

    Returns the first character of the input String.

    Input data pill Output data pill
    String String - Transformed String as the first character of the input String
    Figure 5. Example
    • Input: Madrid
    • Output: M

    In this example, the flow triggers when a User [sys_user] record is created. The flow then updates the City field for the User [sys_user] record with a code that is represented as the first character of the city's name.

    Update the city code for a user.

    Last Character

    Returns the last character of the input String.

    Input data pill Output data pill
    String String - Transformed String as the last character of the input String
    Figure 6. Example
    • Input: Madrid
    • Output: d

    Replace String

    Returns a replaced string from the input string based on the provided regular expression (regex) and replacement string. Use the JavaScript regular expression format.

    Input data pill Parameters Output data pill
    String
    • Regex - Regular expression to be matched for replacement
    • Replace String - Replacement string
    Resulting string after replacement with given parameters
    Figure 7. Example
    • Input: "Example input string."
    • Parameters:
      • Regex: \"
      • Replacement string: \\\"
    • Output: \"Example input string.\"

    Size

    Returns the total number of characters in the input String.

    Input data pill Output data pill
    String Integer
    Figure 8. Example
    • Input: Example input string.
    • Output: 21

    Split

    Returns an Array.String based on a provided Separator that splits the input String. If the Separator field is left blank, the transformation is ignored and the system returns the input String. If entering any data type other than a String as the Separator, the system converts the provided value to a String.

    Input data pill Parameters Output data pill
    String Separator - Enter a delimiter that specifies where the input String should be split. If left blank, the input String is not transformed at runtime. Array.String - An array of substrings from the input String
    Figure 9. Example
    • Input: Example, input, string.
    • Separator: ,
    • Output: ["Example", "input", "string."]

    Starts With

    Returns true when the input string starts with a given sequence of characters.

    Input data pill Parameters Output data pill
    String Characters to search for. Boolean indicating whether the input string starts with the given sequence of characters
    Figure 10. Example
    • Input: Cheese Pizza
    • Parameter: Chees
    • Output: true

    Substring

    Returns a substring from the input String that is based on the provided Start Index and End Index. Input String index starts at 0.

    Input data pill Parameters Output data pill
    String
    • Start Index - Index of the first character to include in the returned substring
    • End Index - Index of the last character to include in the returned substring
    String - Transformed String as a substring of the input String
    Note:
    If the Start Index value is longer than the string's length, then the transform function returns the input string. This behavior is different from the JavaScript substring() method, which instead returns an empty string.
    Figure 11. Example 1
    • Input: Example input string
    • Start Index: 3
    • End Index: 6
    • Output: mple
    Figure 12. Example 2
    • Input: Example input string
    • Start Index: 30
    • End Index: 40
    • Output: Example input string

    To Lower Case

    Converts the input String to all lowercase characters.

    Input data pill Output data pill
    String String in all lowercase characters
    Figure 13. Example
    • Input: ExamPle inpuT stRing
    • Output: example input string

    To Proper Case

    Changes the case of words in the input string. Capitalizes the first letter of each word and makes the remaining letters in the word lower case. A word is considered any string separated by a space, hyphen, backslash, or forward slash character. The transform function always evaluates words from left-to-right to determine the first letter.

    Input data pill Output data pill
    String String in proper case
    Figure 14. Example
    • Input: exAMPle-input string/TEXT
    • Output: Example-Input String/Text

    To Upper Case

    Converts the input String to all uppercase characters.

    Input data pill Output data pill
    String String in all uppercase characters
    Figure 15. Example
    • Input: ExamPle inpuT stRing
    • Output: EXAMPLE INPUT STRING

    Trim

    Removes white space from the beginning and end of the input String. Does not remove white space within the input String.

    Input data pill Output data pill
    String String - Transformed String with trimmed white space
    Figure 16. Example
    • Input: SQL Server APAC 1
    • Output: SQL Server APAC 1

    In this example, the action makes a REST call to a third-party system and GETs a response body containing data about a server. Then, the Trim transform function removes any unwanted white space before adding the server's name to a new record in the Server [cmdb_ci_server] table.

    Trim white space from a server name before adding it to the CMDB.