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
    Jeremy Clarke

    Hi Richard,

    You'll actually want to just set the font size of the merge field in your template :)

  • Avatar
    Richard Lahaie

    Duh, of course! Thanks Jeremy!

  • Avatar
    David Martin

    Hi Jeremy. I created a fillable pdf in Adobe, and formatted the date fields using adobe's text field properties box to be mm/dd/yyyy, then uploaded that to webmerge as my form. The data is pulling from Process Street via Zapier and shows up as yyyy-mm-ddT11:19:00.000Z. I can't find anywhere in either Process Street or Zapier to use the {$StartDate|date_format:"m/d/Y"} code string and get the format to appear as I want it in the merged document. Thanks

  • Avatar
    Jeremy Clarke

    Hi David,

    Unfortunately, the formatting in a fillable PDF doesn't not "stick" when uploading to WebMerge, but you can use the Field Map ( to re-format the date before going into your PDF.

    If your date field is called "ExpirationDate" you'll enter this in the box under ExpirationDate on your Field Map:


    Edited by Jeremy Clarke
  • Avatar
    Antoine Bocqueho

    Hi Jeremy,

    Those functions can't work with a word doc ?

  • Avatar
    Jeremy Clarke

    Hi Antoine,

    Yes, all those functions will work with a Word doc! If you're having specific issues, please create a support ticket and we can help you from there :)


  • Avatar
    Julian Swales

    I need to output a date in French in a document.. I see above that I have to use the following item somehow:
    {$_ = setlocale(LC_TIME, "fr_FR")}
    I'm just not sure how to insert it and the date format together...
    This is my current variable field in the English document version.
    {strtotime($Certificate_Date)|date_format:"F j, Y"}
    I need to output the same field input in the French document in French.

  • Avatar
    Jeremy Clarke

    Hi Julian,

    To print the date in another language, you have to use strftime() like this:

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

  • Avatar
    Julian Swales

    Hi Jeremy,
    So, I don't understand how to set the setlocale for the document in the example above. I understand the strftime will use the setlocale, but how do I define it for that document?

  • Avatar
    Jeremy Clarke

    Hi Julian,

    Simply put the setlocale code at the top of your document:

    {$_ = setlocale(LC_TIME, "fr_FR")}

  • Avatar
    Kimberley Sare

    Hi Jeremy

    I am looking to truncate text but rather than by the number of characters, I want everything up to a "(" sign. Can you help please?

  • Avatar
    Jeremy Clarke

    Hi Kimberley,

    You will want to do something like this:

    {substr($Description, 0, strpos("(", $Description))}

  • Avatar
    Tori Bramble

    I have a question: I want to create an option that you select or input the number of people (i.e., 1, 2, 3, 4, 5, etc) and then depending on the number, it has you input a name and a date. For example, if I say {$NbrofPeople} and the input number is 4, how do I get it to say "Person 1 Name", "Person 1 DOB", "Person 2 Name", "Person 2 DOB", "Person 3 Name", "Person 3 DOB", "Person 4 Name", "Person 4 DOB", Thank you

  • Avatar
    Jeremy Clarke

    Hi Tori,

    You will need to create a merge field in your document for each piece of info like this:

    {if $NbrofPeople >= 1}{$Person1Name} {$Person1DOB}{/if}{if $NbrofPeople >= 2}{$Person2Name} {$Person2DOB}{/if}{if $NbrofPeople >= 3}{$Person3Name} {$Person3DOB}{/if}

  • Avatar
    Jeff Schneider

    Hi Jeremy,

    Is there any way to include total page numbers in the document? Looking to add a sentence like "this document, consisting of (X) pages."


  • Avatar
    Jeremy Clarke

    Hi Jeff,

    It depends on your template type:

    - Document Builder: You can use {nb} in your header/footer for the total pages

    - Word: You can insert a Word "field" that is the total number of pages anywhere in the doc. The easiest way is to do Insert > Page Number, then right click the number and select Edit Field and change it to NumPages.

  • Avatar
    Forrest Chamberlain

    Hi Jeremy,
    How would I convert a CSV to line breaks in an HTML email template? As expected, < br / > is getting stripped.

    Edited by Forrest Chamberlain
  • Avatar
    Jeremy Clarke

    Hi Forrest,

    Is it just a comma separate list of items like this? Red, Green, Blue

    You can try this: {$FieldName|replace:",":"

  • Avatar
    Forrest Chamberlain

    Hi Jeremy,
    Just like the < br / > in your example right above (and mine until I edited it and added spaces), the email editor is stripping the < br / > (or moving it out of the {}).

    It might be nice to have an option to turn off the email WYSIWYG (no just toggle). Perhaps this is a solution to my woes anyway.

    Edited by Forrest Chamberlain
  • Avatar
    Jeremy Clarke

    Hi Forrest,

    Try adding that code to the Field Map ( instead: {$FieldName|replace:",":"\n"}

    then you can just print the merge field normally in the email and it will automatically have the HTML break line it it.

  • Avatar
    Forrest Chamberlain

    Jeremy, ah, thanks!

  • Avatar
    Andres Cuestas

    any way to format from zapier.

  • Avatar
    Jeremy Clarke

    Hi Andres,

    You can format the data inside your template or using the Field Map:

  • Avatar
    Danielle Walker

    Does web merge limit the number of decimals you can submit? For example, I submit a number 1.123456789012345 and on my document, it only includes the first 13 decimal places 1.1234567890123.

  • Avatar
    Jeremy Clarke

    Hi Danielle,

    Can you try doing something like this: {$field_name|round:13}

  • Avatar
    Danielle Walker

    Jeremy- Sorry to be more clear I want all 15 decimals. But webmerge is only displaying 13.

  • Avatar
    Jeremy Clarke

    Hi Danielle,

    Sorry, try using a "15" instead like this: {$field_name|round:15}

  • Avatar
    Kimberley Sare

    Hi Jeremy

    Can you help please? I want to set the file name of a document from a series of variables in the document. I have added the following to my document and then used the variable $filename as the file name in the webmerge settings but all that I am getting when I test is the name of the document called "filename", rather than the details.

    {$filename=$_date + $client1informal|abbreviation|upper + $client2informal|abbreviation|upper + $client1surname|truncate:3|upper + $reportname}

  • Avatar
    Jeremy Clarke

    Hi Kimberley,

    Unfortunately, you cannot set the value of a merge field inside a document then use that value outside the document in other settings. You'd have to use the Field Map to set the value.

    But with the filename setting, all you need to do is select <> from the dropdown then enter your merge fields like:

    {$_date} {$client1informal|abbreviation|upper} {$client2informal|abbreviation|upper} {$client1surname|truncate:3|upper} {$reportname}

  • Avatar
    Mike Barrette

    I am using a Word Doc template for an application form. The data is coming in using Formstack with a Zap. I am trying to get the Signature image on the Word Doc (it's coming through as a URL so I need some way to convert it to an image. I know with the Build-Your-Own option I can embed the signature field within image html tags and it display nicely in the PDF output. However in the Word Doc, it displays the HTML tags and full URL. Suggestions?

Please sign in to leave a comment.
Powered by Zendesk