> For the complete documentation index, see [llms.txt](https://docs.getmesa.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.getmesa.com/workflow-builder/fields/formatting-variables.md).

# Formatting Variables

Formatting variables is a way to filter and format your [variables](https://docs.getmesa.com/workflow-builder/fields/variables) that produce strings, numbers, arrays, and dates.

This is a great feature to use when you want to simplify complex data like dates produced in [ISO 8601 date and time](https://www.iso.org/iso-8601-date-and-time-format.html) formatting (2008-01-10T11:00:00) and have the values converted to a more readable format like MM/DD/YY (10/01/08).

<figure><img src="/files/rQ78hW6Qqd0pN1znYWbb" alt="Screenshot of the MESA workflow builder formatting a variable, converting an ISO 8601 date into a readable MM/DD/YY format. Spotlight the formatted date variable."><figcaption></figcaption></figure>

## How to Format Variables

To format variables, click the vertical 3-dot icon at the right of any variable to open the Step Options, then click Format.

<figure><img src="/files/UCfIkFc7n7fypTslHiN2" alt="Screenshot of the MESA workflow builder, open the Step Options with the vertical 3-dot icon on a variable. Spotlight the Format option."><figcaption></figcaption></figure>

You will then be able to format your variable's output using the formatting options that populate within the sidebar menu.

<figure><img src="/files/sc6TrhGzvjBWUr1SVemd" alt="Screenshot of the MESA workflow builder Formatting Options sidebar menu for a variable. Spotlight the formatting options in the sidebar."><figcaption></figcaption></figure>

## Formatting Options

Within the Formatting Options sidebar menu, you'll be able to adjust the value your variable produces based on its type.

<details>

<summary>Date</summary>

* **Add time:** Adds a specified amount of time to a date.
* **Format:** Converts a date into a different format.
* **Start of day:** Converts a date to the start of the day (00:00:00).
* **End of day:** Converts a date to the end of the day (23:59:59).
* **Subtract time:** Subtracts a specified amount of time from a date.
* **Time between:** Calculates the time difference between two dates.
* **Time since:** Calculates the time difference from a date to now.

</details>

<details>

<summary>String</summary>

* **Append:** Adds text to the end of a string.
* **Capitalize:** Capitalizes the first word in a string and downcases the remaining characters.
* **Downcase:** Converts all letters to lowercase.
* **Prepend:** Adds text to the beginning of a string.
* **Remove last:** Removes the last instance of a substring inside a string.
* **Replace:** Replaces all occurrences of specific text within a string.
* **Replace last:** Replaces only the last occurrence of specific text within a string.
* **Split:** Breaks a string into an array based on a separator.
* **Strip:** Removes spaces from the beginning and end of a string.
* **Strip HTML:** Removes all HTML tags from a string.
* **Upcase:** Converts all letters to uppercase.

</details>

<details>

<summary>Math</summary>

* **At least:** Ensures a number is no smaller than a set minimum.
* **At most:** Ensures a number is no larger than a set maximum.
* **Divided by:** Divides a number and keeps the same type (integer or decimal).
* **Minus:** Subtracts one number from another.
* **Plus:** Adds two numbers.
* **Round:** Rounds a number to the nearest whole number.
* **Times:** Multiplies a number by another number.

</details>

<details>

<summary>Array</summary>

* **Compact:** Removes empty values from an array.
* **Concat:** Combines two arrays into one.
* **First:** Retrieves the first item in an array.
* **Join:** Combines all of the items in an array into a single string, separated by a space.
* **Last:** Retrieves the last item in an array.
* **Map:** Extracts values from a specific property in an array of objects.
* **Size:** Returns the length of a string or the number of items in an array.
* **Sort by an array item property:** Sorts the items in an array in case-insensitive alphabetical order.
* **Sum:** Adds up all numbers in an array.

</details>

To apply your formatting, fill out one of the options based on the type you're working with and click apply.

<figure><img src="/files/ddh8DqX28XU9PwitHaRC" alt="Screenshot of the MESA Formatting Options sidebar, fill out an option based on your variable type. Spotlight the Apply button."><figcaption></figcaption></figure>

You can add multiple combinations of formatted options to create the precise variable value that you need. They will be listed in the order that you apply them within the top of the Formatting Options sidebar.

<figure><img src="/files/wS9ReDMs7nm1XeHumAOI" alt="Screenshot of the MESA Formatting Options sidebar with multiple applied format options listed in order. Spotlight the list of applied formatting options at the top."><figcaption></figcaption></figure>
