Skip to main content
All CollectionsPromptsWriting Prompts
Advanced: Filter Input Variables
Advanced: Filter Input Variables

Modify the value of an Input Variable before it's inserted into your prompt to improve formatting and more.

Promptitude Team avatar
Written by Promptitude Team
Updated over a week ago

Quick recap: Input Variables turn your prompts into reusable, interactive tools. So for every part of your prompt that changes each team the prompt is used, you create an Input Variable.

Filters help you modify what is inserted into your prompt after someone enters it into an Input Variable. Let's start with a simple example.

Example: Joke Generator

In the above example, the Input Variable {{name}} inside the Prompt will be replaced with whatever name you or your users enter into the field - for example with John. Here's the generated Result:

Why did John the developer switch to decaf coffee?
Because he heard the Java was causing too many bugs!

But what if someone enters "john" (lowercase) or "JOHN" (all caps) into the Input Variable? In that case, the Result looks like this:

Why did john the developer switch to decaf coffee?
Because he heard the Java was causing too many bugs!

Filters to the Rescue

This is where Filters come in handy. Instead of using the simple variable {{name}} in your prompt, you can add a filter to it to modify its value.

For example, to always capitalize the value of the Input Variable, use the capitalize filter like so: {{name | capitalize}}

This will automatically capitalize the first letter of the value before it's being inserted into your prompt.

So even if someone enters "john" into the Input Variable, the capitalize filter will make sure that instead, "John" is being inserted into the prompt - cool, right?

How to Use Filters

Adding a filter to an Input Variable inside your prompt is easy:

  1. Copy and paste the Input Variable into your prompt as usual (or enter it), if you haven't done that already:
    {{name}}

  2. Inside the curly brackets, enter an empty space, a vertical line (pipe), and another space:
    {{name | }}

  3. Finally, enter the name of the filter after the vertical line:
    {{name | capitalize}}

The good news: There are many different filters you can use to modify the value of an Input Variable!

Available Filters

Here's a list of the most useful filters - just replace "capitalize" in the above example with the exact name of the filter you want to use:

Filter

Value of Input Variable

What's inserted into the Prompt

{{name | capitalize}}

john

John

{{name | downcase}}

Project Manager

project manager

{{name | upcase}}

Good news

GOOD NEWS

You can even remove certain words or phrases from the Input Variable, or replace them with different words. You can find all available text filters here.

Conclusion

Filters are an advance way to get the best results out of your Prompts. Once you know how they work, they're actually pretty easy and fun to use.

Any final questions? Missing a filter? Just email us: [email protected]

Did this answer your question?