![](https://help.apple.com/assets/5B9014F10946229C37C593B4/5B9014F50946229C37C593C7/en_US/c10e8a839dc838a25d0feb0e9e428a0a.png)
Use variables in Shortcuts
In Shortcuts, you can:
Place a variable in a text field: For example, you can place a variable in the text field of an email shortcut, letting you choose a specific salutation (such as “Dear Sir” or “Dear Madam”) when you run the shortcut.
Pass the contents of a variable as an input to an action: You can manually save the output of any action into a variable and reuse the contents of that variable later in the shortcut. For example, in a shortcut that grabs a book title, you can use a Get Variable action to save the name of the book into a variable. You can then pass the contents of that variable (the book title), into a later action in the shortcut.
Use a variable to replace an action’s parameter (a setting within an action): You can embed a variable in an action. For example, you can place an Ask When Run variable in the Repeat parameter of a Play Music action, letting you choose whether or not to repeat a song when you run the shortcut.
Variables are represented by small, pill-shaped tokens, such as, or
.
Add a variable to a text field
In the Shortcuts app Library
, tap
on the shortcut you want to modify, then tap any text field in an action.
Note: Not all actions contain text fields.
The Variables bar and keyboard are displayed.
Tap Variables.
The Variables bar expands, displaying the
Select Magic Variable button and all of the manual or Magic Variables made available by previous actions.
Tap
Select Magic Variable.
The shortcut editor displays an alternate view showing each action’s output as an available variable, ready for selection.
Tap the variable that you want to add to the text field you selected in step 1.
The variable is placed inline in the text field (at the original insertion point); this is where the stored data will be placed when the shortcut is run.
You can continue to use the Variables bar to access Magic Variables that you may want to add.
Optional: To add one of the four types of special variables, tap Done, tap a text field, tap Variables, then tap one of the following special variables that appear as green tokens:
Ask When Run: Prompts you to enter text in its place when the shortcut is run.
Clipboard: Inserts what you’ve most recently copied at the time the shortcut runs.
Current Date: Inserts today’s date and time, formatted to your preference.
Shortcut Input: Grabs the input that was passed into the beginning of the shortcut (applicable for shortcuts that are set to the Action Extension type).
Note: On iPhone, you may need to swipe left to see all four special variables.
The special variable is placed inline in the text field (at the original insertion point).
Remove a variable
In the Shortcuts app Library
, tap
on the shortcut you want to modify.
Do one of the following:
In a text field: Position the cursor in front of the variable in the text field, then tap
in the onscreen keyboard.
In an action’s parameter: Tap the variable token to select it, then tap Clear (to the left of the Rename button).
Pass the contents of a variable as input into another action
In the Shortcuts app Library
, tap
on the shortcut you want to modify.
Place a Get Variable action above the action that will receive the input, then tap Choose Variable.
In this example, a Magic Variable is available.
Tap Select Magic Variable, then tap a variable in the shortcut editor.
When the shortcut is run, the content of the variable chosen in step 3 is retrieved and passed as input into the action following the Get Variable action.
Replace a parameter with a variable
You can replace an action’s parameter (a setting within an action) with a variable, allowing you to dynamically switch between the settings of an action while a shortcut is running.
In the Shortcuts app Library
, tap
on the shortcut you want to modify.
In the shortcut editor, tap any parameter name, then choose a replacement variable from the list that appears.
Important: Your variable must contain the correct content. For example, to place a variable as the parameter in the Get Trello Items action, your variable must have a value of either Boards, Lists, or Cards. For parameters with on/off switches, use a 1 or 0 to set the button as active or inactive, respectively.
In this example, the Chosen Item variable replaces the Boards parameter in the Get Trello action.