Formatting Your Data

There are many different ways to format your data. In this post, when we talk about formatting, we don’t mean styling (font, color, etc) – we are talking about altering the format of your data. For example, you have created a document that includes numbers, but the data comes through without pretty formatted numbers that include commas to separate the thousands. Or you may want to convert a word to all lowercase. Much of this formatting can be done pretty easily.

To format the merge field data, we're going to use what is called a "modifier".  This is a little piece of code that is added after the merge field name, separated with a pipe "|".

Here is a list of available modifiers:

Name Description Example
abbreviation Convert text to abbreviation (grab first letter of each word)

John Smith = JS

John Smith = J.S.

add_days Add days to date


age Convert date into age (years)


age_to_words Convert date into age in words

{$Birthdate|age_to_words} = 2 years 3 days 4 hours

bitly Convert URL to Bitly link


calendar Make calendar from array of dates


$dates = [{"name":"Make Offer", "date":"3/5/2017"}, {"name":"Submit Escrow  Check", "date":"3/21/2017"}, {"name":"Close Deal", "date":"4/15/2017"}]

capitalize Capitalize the first letter of a merge field


capitalize_sentences Capitalize the first word in each sentence


cat Append text to the end of a merge field

{$Name|cat:" is ready"}

csv_to_array Convert CSV string (or URL) to an array

{$csv = $file_url|csv_to_array}

currency_format Format a currency value

{$TotalAmount|currency_format:"$"} = $1,298.99

International Format:

date_format Change the format of a date

{strtotime("+ 5 days", strtotime($_date))|date_format:"m/d/Y"}
For more options, check out

decimal_to_words Convert a decimal/number to words

{$Ratio|decimal_to_words} = three and 7 tenths

default Set a default value for a merge field


expand_url Get real URL (follow redirects) from a shortened URL


get_file Download file from URL

{$text = $url|get_file}

html_safe Convert characters to HTML safe characters


html2office Convert HTML to Office doc formatting


html2text Convert HTML to plain text


implode Combine list of array values into single string with a separator

{implode(", ", $Colors)}
comma separated list of the $Colors

int_number Convert international number to US format (for calculations) 

 {$Total = $Subtotal|int_number + $Tax|int_number}

list List array values in a commas separated list

{$Colors|list:",":"and"} = Red, Green, and Blue

lower Convert all characters to lowercase

Formstack Documents = formstack documents

markdown2html Convert markdown to html


money_to_words Convert price to words

10.50 = ten dollars and 50 cents

11 = eleven euros

nl2 Convert new-line characters to given string

{$Description|nl2:", "}

nl2br Convert new-line characters to HTML line breaks <br>


nl2p Convert new-line characters to HTML paragraph


number Convert merge field to a number (for calculations)

10,231 = 10231

number_eu_to_us Converts a number from EU format to US


number_us_to_eu Converts a number from US format to EU


number_format Change the format of a number (commas and decimals)

5234.35 = 5,234.35

International format (comma for decimal place)

number_to_words Convert number to words


pad Pad merge field with the given string, so it is the given length

123456 = 00000012345

parse_url Searches string for a URL


phone_format Format a phone number

{$WorkPhone|phone_format:"(%3) %3-%4"}
123-555-7890 = (123) 555-7890

{$phone|phone_format:"%3.%3.%4"} = 123.456.7890

replace Search and replace a string in a merge field

123 S Main Street = 123 S Main St

round Round a number to number of decimal places provided


spacify Insert a space (or string) in between each character in merge field

Thomas = T h o m a s

123456 = 1-2-3-4-5-6

state_abbreviation Convert US State name to abbreviation


strip Replace all new lines, spaces, and tabs with a single space


strip_tags Remove all HTML tags from merge field

{$Description|strip_tags:"<br>"} (allow <br>)

substr Create a sub-string of the merge field


text2html Convert text to HTML


time_to_words Creates a text representation of the number of seconds


translate Translate text into another language


via Google Translate - Languages

truncate Truncate/shorten the merge field to the given length

{$Description|truncate:140}    (140 characters)

ucfirst Capitalize the first letter in the first word


ucwords Capitalize the first letter in each word


upper Convert all characters to uppercase

Formstack Documents = FORMSTACK DOCUMENTS

xml_safe Encode merge field data for XML (Office) docs

{strftime("%d %B %Y", strtotime($_date))|ucwords|xml_safe}


  • International Date/Translation
    • You can print a date like this: {strftime("%d %B %Y", strtotime($_date))|ucwords}
    • More formatting options for strftime:


For more information on using variable modifiers, please visit

Have more questions? Submit a request


  • Avatar
    Edgar Jameson

    In my form I have a collection of check boxes. How would I wordwrap and comma seperate the selected values? I'm not seeing anything like that in the smartly data.

  • Avatar
    Jeremy Clarke

    Hi Edgar,

    You could use the "implode" function that combines a list of items (an array) into a single string like this: {implode(", ", $Colors)}

    The first part is the "separator" which you can be a space, comma; semi-colon, etc, then the 2nd part is the merge field (array)

  • Avatar
    Carrier Pastor

    How would one have 5,000 from a .csv merge to 5,000 (no decimals, but a comma for '000s) in a document. I have used several versions of number format and end up with no number at all, or 5. Thanks for your help!

  • Avatar
    Jeremy Clarke

    Hi Tammy,

    If you have commas in the number, you need to convert the value to a number (using the "number" modifier) before you do any calculations of formatting. You can do this:

    {$Total|number / 10}

  • Avatar
    Carrier Pastor

    Is this the correct Mailing Address Block Format if I want to include the Title of the recipient? If there is not Title then will it automatically pull in the Account Name with out causing a line break? Same things for Mailing Address 1 and 2?

    {$First_Name} {$Last_Name}
    {$Title}{if !empty($Account_Name)}
    {$Mailing_Street}{if !empty($Mailing_Street2)}
    {$Mailing_City}, {$Mailing_State} {$Mailing_Zip_PostalCode}

  • Avatar
    Jeremy Clarke

    Close! You'll want to make sure you use an "if" statement around your Title field too:

    {$First_Name} {$Last_Name}{if !empty($Title)}
    {$Title}{/if}{if !empty($Account_Name)}
    {$Mailing_Street}{if !empty($Mailing_Street2)}
    {$Mailing_City}, {$Mailing_State} {$Mailing_Zip_PostalCode}

  • Avatar
    Kimberley Sare

    Thanks for this Jeremy. Can you please let me know how I would modify a currency field so that it rounds up to the nearest pound/dollar? The data is coming from Knack and is a currency field.

  • Avatar
    Jeremy Clarke

    Hi Kimberley,

    You'll want to use the "round" modifier like this:


    If you're field value has commas or dollar signs in it, you need to convert to a number first like this:


  • Avatar
    Kimberley Sare

    Thanks Jeremy - you're super helpful.

    Now I am trying to add three months to a date which is coming from the source as a date?

  • Avatar
    Jeremy Clarke

    Hi Kimberley,

    You can do something like this:

    {strtotime("+ 3 months", strtotime($TheDate))|date_format:"m/d/Y"}

  • Avatar
    Lance Velasco

    Is there an option to currency? I have numbers formatted as "5000" and would like to output "$5,000.00"

  • Avatar
    Jeremy Clarke

    Hi Lance,

    Yes, you'll use the "number_format" modifier and put a $ sign before the merge field like this:


  • Avatar
    Lance Velasco


    But then if the field comes through as NULL then it will just be $, so would this need to be wrapped in an IF statement prior?

    Edited by Lance Velasco
  • Avatar
    Jeremy Clarke

    Hi Lance,

    Yes, you could do something like this:

    {if !empty($Total)}${$Total|number_format:2}{/if}

  • Avatar
    Lance Velasco


    So the if in this case does not require an else?

  • Avatar
    Jeremy Clarke

    Hi Lance,

    You only need to use {else} if you want to print something when $Total is NULL (empty).

  • Avatar
    Kimberley Sare

    Hi Jeremy

    I am trying to round a calculated percentage to the nearest whole number. I have tried {(($CETV|number/1000000)*100)|round}% but I'm getting an error?

    Can you also tell me how I would round to two decimal places please?
    Thanks in advance

  • Avatar
    Jeremy Clarke

    Hi Kimberley,

    Try this: {((($CETV|number)/1000000)*100)|round:2}%

  • Avatar
    Martin Simmermann

    Hi Jeremy!

    Client submits his social security number ($SocialNr), for example 01012950000 and I need to know how old the client is.

    I created {assign var="SixNr" value=$SocialNr|substr:1:-4} and the result is 101295. That means that the client was born on 10th of December 1995.

    I would like to convert the numbers 101295 to date (10.12.1995), so that I would be able to use {$...|age}. Thank you!

  • Avatar
    Jeremy Clarke

    Hi Merilin,

    Try this:


  • Avatar
    Kimberley Sare

    Hi Jeremy

    You helped me with this once already but I am trying to get this to round to the nearest whole number - i.e. no decimals - instead it is only pulling through the numbers before the comma ...


  • Avatar
    Jeremy Clarke

    Hi Kimberley,

    You need to use round before number_format, so try this instead:


    Edited by Jeremy Clarke
  • Avatar
    Faisal Velani

    I have a date field called {$Invoice_Date}. How can I add 30 days to that field?

  • Avatar
    Jeremy Clarke

    Hi Faisal,

    Like this: {strtotime("+ 30 days", strtotime($Invoice_Date))|date_format:"m/d/Y"}


  • Avatar
    Cory Harrison

    I am pulling data out of Podio, and there is a "duration" field, which has the unit of hours in Podio. When it's pulling into my webmerge, it appears to be calculating in seconds, rather than hours. So rather than my merged doc saying "1" hour(s), it's saying "3600" hour(s). How can I format to have it convert?

  • Avatar
    Jeremy Clarke

    Hi Cory,

    You could do something like this: {round($Duration / 3600)} hour(s)

  • Avatar
    Cory Harrison

    Thank you, Jeremy! Worked perfectly.

  • Avatar
    Matt Williams

    Is there an easy way to take a hubspot UNIX timestamp and convert that to a date in DD/MM/YYYY using this formatting method? We''re trying to output a hubspot date field and have that appear in the .pdf from webmerge but can't get it working properly... Currently trying to do it via the formatter in Zapier but getting some funky results with certain dates!

  • Avatar
    Jeremy Clarke

    Hi Matt,

    You should be able to do this in your template: {$DateFieldName|date_format:"d/m/Y"}

    If you're using a fillable PDF, you'll need to use the Field Map ( to format the date before it goes into the PDF

  • Avatar
    Richard Lahaie


    What modifier/function is used to resize fonts?

Please sign in to leave a comment.
Powered by Zendesk