---
title: "GravityView Merge Tag modifiers"
date: 2026-04-23
author: "GravityKit"
link: "https://www.gravitykit.com/docs/gravityview/merge-tags/merge-tag-modifiers/"
---

# GravityView Merge Tag Modifiers

GravityView heavily uses [Gravity Forms Merge Tags](https://docs.gravityforms.com/category/user-guides/merge-tags-getting-started/), in addition to [adding new ones](https://www.gravitykit.com/docs/gravityview/merge-tags/merge-tags/).

To enhance Merge Tags, GravityView adds additional "modifiers" that allow you to format Merge Tags differently.

## GravityView Modifiers

### String formatting

- `:wpautop` - Converts line breaks into HTML paragraphs; runs `wpautop()` on the output
- `:wptexturize` - Applies WordPress "texturize" formatting (curly quotes, em-dashes, etc.); runs `wptexturize()` on the output
- `:esc_html` - Makes field output safe to use in HTML attributes; runs `esc_html()` on the output
- `:sanitize_html_class` - Makes output safe for use as CSS class names; runs `sanitize_html_class()` on the output
- `:sanitize_title` - Creates URL-friendly slugs; runs `sanitize_title()` on the output
- `:urlencode` - URL-encodes the output for use in query strings; runs `urlencode()` on the output
- `:rawurlencode` - URL-encodes the output per RFC 3986, encoding spaces as `%20` ; runs `rawurlencode()` on the output
- `:maxwords:{number}` - Limits output to `{number}` of words

### Case transformation

- `:strtolower` - Converts the entire output to lowercase
- `:strtoupper` - Converts the entire output to uppercase
- `:ucfirst` - Capitalizes the first character of the output
- `:ucwords` - Capitalizes the first character of each word

### Name formatting

- `:initials` - Converts a full name to initials (e.g., "John Doe" becomes "JD")

### Date and time formatting

- `:timestamp` - Converts a date field value to a [Unix timestamp](https://en.wikipedia.org/wiki/Unix_time)
- `:human` - Displays dates and times in a human-readable relative format (e.g., "2 hours ago", "3 days ago")
- `:format:{format}` - Formats date and time field merge tags using [WordPress date format strings](https://wordpress.org/documentation/article/customize-date-and-time-format/)

### Multi-value fields

- `:explode` - Converts JSON or CSV values into a space-separated string (useful for Multiple Select fields)

**Note**: These modifiers will not be processed on `{all_fields}` Merge Tags.

---

## Usage: `:esc_html` Modifier

The `:esc_html` modifier runs the output of the field through [the `esc_html()` function in WordPress](https://developer.wordpress.org/reference/functions/esc_html/).

Before, you weren't able to use Merge Tags when generating HTML. This modifier makes field output safe for HTML, and allows you to use Merge Tags inside HTML attributes safely:

> `{Business Name:2}` is `The "World's Best" Astronaut Ice Cream`

**Before:**

Without the Merge Tag modifier, you would use this code:

```
{Business Name:2}
```

```
{Business Name:2}
```

And the output would be broken HTML:

```
The "World's Best" Astronaut Ice Cream
```

```
The "World's Best" Astronaut Ice Cream
```

Notice the extra double quotes inside the HTML tag? That is broken HTML.

**After:**

Let's update the example to use the `:esc_html` modifier:

```
{Business Name:2:esc_html}
```

```
{Business Name:2:esc_html}
```

## The output is now valid HTML, with the quotes converted to HTML entities:

```
The "World's Best" Astronaut Ice Cream
```

```
The "World's Best" Astronaut Ice Cream
```

## Usage: `:sanitize_html_class` Modifier

This modifier is perfect for making sure the field values are valid CSS class names. Use it inside your HTML, like so:

```
[...]
```

```
div class="{Category:5:sanitize_html_class}">[...]div>
```

The `:sanitize_html_class` modifier runs the field output through the `gravityview_sanitize_html_class()` function, which is very similar to the `sanitize_html_class()` WordPress function, except the WordPress function does not allow spaces (multiple CSS classes), and GravityView does.

**Before:**

- Merge Tag: `{Your Profession:5}`
- Value: `Scientist, Astronaut!`

**After:**

- Merge Tag: `{Your Profession:5:sanitize_html_class}`
- Value: `Scientist Astronaut`

---

## Usage: `:sanitize_title` Modifier

The `:sanitize_title` modifier runs the field output through the `sanitize_title()` WordPress function.

This is convenient for adding standardized attributes to HTML tags.

**Before:**

- Merge Tag: `{Your Profession:5}`
- Value: `Scientist, Astronaut!`

**After:**

- Merge Tag: `{Your Profession:5:sanitize_title}`
- Value: `scientist-astronaut`

---

## Usage: `:urlencode` Modifier

The `:urlencode` modifier URL-encodes the output, making it safe to use in query strings.

**Before:**

- Merge Tag: `{Search Query:7}`
- Value: `rocket science & space travel`

**After:**

- Merge Tag: `{Search Query:7:urlencode}`
- Value: `rocket+science+%26+space+travel`

This is useful when building URLs dynamically:

```
https://example.com/search?q={Search Query:7:urlencode}
```

```
https://example.com/search?q={Search Query:7:urlencode}
```

## Usage: `:rawurlencode` Modifier

The `:rawurlencode` modifier URL-encodes the output according to [RFC 3986](https://www.rfc-editor.org/rfc/rfc3986). Unlike `:urlencode` , which encodes spaces as `+` , `:rawurlencode` encodes spaces as `%20` . This makes it more suitable for encoding URL path segments and safer for use with email links.

This modifier runs the [rawurlencode()](https://www.php.net/manual/en/function.rawurlencode.php) function on the Merge Tag's content.

**Before:**

- Merge Tag: `{Search Query:7}`
- Value: `rocket science & space travel`

**After:**

- Merge Tag: `{Search Query:7:rawurlencode}`
- Value: `rocket%20science%20%26%20space%20travel`

Use `:rawurlencode` when building URLs that need to be used in emails.

```
email us
```

```
email us
```

## Usage: `:wpautop` Modifier

The `:wpautop` modifier changes double line breaks in the text into HTML paragraphs (`...` ) and single line-breaks are converted to HTML `` . Line breaks within the script and style sections are not affected.

This modifier will run the [wpautop()](https://codex.wordpress.org/Function_Reference/wpautop) function on the Merge Tag's content. [Learn more on WordPress.org](https://codex.wordpress.org/Function_Reference/wpautop).

**Before:**

- Merge Tag: `{Cosmonaut:4}`
- Output: `The Earth was small and light blue.`

**After:**

- Merge Tag: `{Cosmonaut:4:wpautop}`
- Output: `The Earth was small and light blue.`

---

## Usage: `:wptexturize` Modifier

The `:wptexturize` modifier applies WordPress "texturize" formatting, which converts straight quotes to curly quotes, double hyphens to em-dashes, and other typographic improvements.

This modifier will run the [wptexturize()](https://developer.wordpress.org/reference/functions/wptexturize/) function on the Merge Tag's content.

**Before:**

- Merge Tag: `{Quote:8}`
- Value: `She said "Hello" -- and then left...`

**After:**

- Merge Tag: `{Quote:8:wptexturize}`
- Value: `She said "Hello" — and then left…`

---

## Usage: `:maxwords:{number}` Modifier

Limits the length of displayed field content to `{number}` words.

When the content length exceeds the number of words, "…" will be appended to the text. Example: "The text is too long" becomes "The text…".

### Example: Display the first 10 words of a testimonial

We have a form named "Testimonial", where we gather customer feedback. It has a textarea field called "Quote", and it has the field ID of "12".

To display the content in GravityView, we normally use the `{Quote:12}` Merge Tag. The full quote is too long, though:

> I really enjoyed the service that I received. Thank you for all your help! In the future, I will have no reservations about referring people to your business. Thanks again!

*That quote has 30 words.* We only want to show the first 10 words so the content fits nicely in our heading. We can use the `:maxwords` modifier to limit the number of words.

We can add the `:maxwords` modifier to the end of the Merge Tag, along with the max number of words we want: `:maxwords:10` . The final Merge Tag looks like `{Quote:12:maxwords:10}` .

Here's the output from the `{Quote:12:maxwords:10}` Merge Tag:

> I really enjoyed the service that I received. Thank you…

### Notes

- Commas, periods, etc, connected to the final word of the value will be preserved.
    - If you set `:maxwords:3` on this value: `Example with comma, to be trimmed` , the output would be `Example with comma,…`
- *HTML tags are preserved.* Whitespace between tags will make an HTML tag be considered a separate word:
    - ` Example` will be considered two words because there is a space between `` and `` .
    - `Example` will be considered one word.

- *HTML entities are allowed.* If they are separated by word breaks, they will be counted as words:
    - `Foo & Bar` will be considered three words because `&` is separate.
    - `Foo& Bar` will be considered two words because `&` is connected to `Foo` .

- When the text is truncated, "…" is appended to the output, using HTML entity `…` .

---

## Usage: Case Transformation Modifiers

GravityView provides four modifiers for transforming the case of text:

### `:strtolower` 

Converts the entire output to lowercase.

**Before:**

- Merge Tag: `{Name:3}`
- Value: `JOHN DOE`

**After:**

- Merge Tag: `{Name:3:strtolower}`
- Value: `john doe`

### `:strtoupper` 

Converts the entire output to uppercase.

**Before:**

- Merge Tag: `{Name:3}`
- Value: `John Doe`

**After:**

- Merge Tag: `{Name:3:strtoupper}`
- Value: `JOHN DOE`

### `:ucfirst` 

Capitalizes only the first character of the output.

**Before:**

- Merge Tag: `{Description:4}`
- Value: `rocket scientist`

**After:**

- Merge Tag: `{Description:4:ucfirst}`
- Value: `Rocket scientist`

### `:ucwords` 

Capitalizes the first character of each word.

**Before:**

- Merge Tag: `{Job Title:5}`
- Value: `senior rocket scientist`

**After:**

- Merge Tag: `{Job Title:5:ucwords}`
- Value: `Senior Rocket Scientist`

---

## Usage: `:initials` Modifier

The `:initials` modifier converts a full name to initials. This is useful for displaying abbreviated names or creating avatar placeholders.

**Before:**

- Merge Tag: `{Name:3}`
- Value: `John Michael Doe`

**After:**

- Merge Tag: `{Name:3:initials}`
- Value: `JMD`

---

## Usage: `:timestamp` Modifier

The `:timestamp` modifier converts valid dates into a timestamp (the number of seconds since the Unix Epoch, January 1 1970 00:00:00 GMT). This is helpful for use in combination with the `[gvlogic]` shortcode.

This modifier will run the [strtotime()](http://php.net/manual/en/function.strtotime.php) function on the Merge Tag's content. If not a valid format, the value will be returned as `-1` .

**Before:**

- Merge Tag: `{Date:3}`
- Output: `07/07/2003`

**After:**

- Merge Tag: `{Date:3:timestamp}`
- Output: `1057547880`

It will work with any format for the Date field (`mm/dd/yyyy` , `yyyy-dd-mm` , and everything in between):

**Before:**

- Merge Tag: `{Text Field With Parseable Date:6}`
- Output: `July 14, 2015, 11:49 GMT`

**After:**

- Merge Tag: `{Text Field With Parseable Date:6:timestamp}`
- Output: `1436874540`

### Notes

- The `:timestamp` modifier is designed to work with Date fields, but it will work for any field, as long as the value is formatted in a way that is parsed by PHP's [strtotime()](http://php.net/manual/en/function.strtotime.php) function.

---

## Usage: `:human` Modifier

The `:human` modifier displays dates and times in a human-readable relative format. This is useful for showing how long ago something happened.

This modifier works with Date and Time fields.

**Before:**

- Merge Tag: `{Date Created:date_created}`
- Value: `2024-01-15 10:30:00`

**After:**

- Merge Tag: `{Date Created:date_created:human}`
- Value: `2 weeks ago`

For Time fields:

**Before:**

- Merge Tag: `{Appointment Time:6}`
- Value: `14:30`

**After:**

- Merge Tag: `{Appointment Time:6:human}`
- Value: `3 hours from now`

---

## Usage: `:format:{format}` Modifier

The `:format` modifier allows you to format date and time fields using [PHP date format strings](https://www.php.net/manual/en/datetime.format.php), which are the same [format strings supported by WordPress](https://wordpress.org/documentation/article/customize-date-and-time-format/).

This modifier works with Date fields, Time fields, and date-related merge tags like `{date_created}` , `{date_updated}` , `{now}` , `{yesterday}` , and `{tomorrow}` .

**Examples:**

- `{Date:3:format:F j, Y}` → `January 15, 2024`
- `{Date:3:format:m/d/Y}` → `01/15/2024`
- `{Date:3:format:Y-m-d}` → `2024-01-15`
- `{Time:4:format:g:i A}` → `2:30 PM`
- `{Time:4:format:H:i}` → `14:30`

### Notes

- To include a colon (`:` ) in your format string, escape it with a backslash: `{Time:4:format:H:i:s}` → `14:30:00`
- The `:format` modifier preserves the original timezone of Date fields (no timezone offset is applied).

---

## Usage: `:explode` Modifier

The `:explode` modifier converts JSON arrays or comma-separated values into a space-separated string. This is particularly useful for Multiple Select fields or other fields that store multiple values.

**Before (JSON array):**

- Merge Tag: `{Categories:5}`
- Value: `["Science","Technology","Space"]`

**After:**

- Merge Tag: `{Categories:5:explode}`
- Value: `Science Technology Space`

**Before (CSV):**

- Merge Tag: `{Tags:6}`
- Value: `rocket,satellite,launch`

**After:**

- Merge Tag: `{Tags:6:explode}`
- Value: `rocket satellite launch`

This is especially useful when you want to use field values as CSS classes:

```
[...]
```

```
div class="{Categories:5:explode,sanitize_html_class}">[...]div>
```

## Using Multiple Modifiers at a Time

You can combine multiple modifiers by separating them with commas. **Be sure to use GravityView's modifiers first, then** [**Gravity Forms’**](https://docs.gravityforms.com/field-merge-tags/#h-modifiers)**.**

For example, if you want to use `:wpautop` but you also want to URL-encode the output, you would write it like this: `{Field:1:wpautop,urlencode}`

**More examples:**

- `{Name:3:strtolower,sanitize_html_class}` - Convert to lowercase, then make safe for CSS classes
- `{Description:4:maxwords:20,wpautop}` - Limit to 20 words, then add paragraph tags
- `{Categories:5:explode,sanitize_html_class}` - Convert array to space-separated string, then sanitize for CSS