I have a Data Extension with some text fields. In the text fields have copy text with newlines.

When I output this copy text when rendering the email I would like to replace the newlines from the Data Extension fields into with <br/>.

Is there any workaround with AMPScript?

2 Answers 2


You can use the replace() AMPscript function:


var @copyText, @copyTextAdj
set @copyText = AttributeValue("copyText")
set @copyTextAdj = replace(replace(@copyText ,char(13),""), char(10),"<br/>")

<br>Adjusted: %%=v(@copyTextAdj)=%%


Function Index

  • Hello Adam, thanks a lot. But this doesn't work for me. But i solved it with SSJS. Nov 1, 2016 at 13:53
  • Updated my example to replace carriage return and linefeed. Nov 1, 2016 at 13:58
  • thanks Adam. Its working now. And thanks for the hint of overhead processing. Nov 1, 2016 at 14:20

I solved that issue with SSJS:

var text = Variable.GetValue("@copytext");
var newtext = text.replace(/[\r\n]/g,"
"); //Set the Variable to be accessible in AMPscript Variable.SetValue("@newcopytext",newtext);
  • 1
    There's extra overhead processing with SSJS in an email. AMPScript is a better choice -- if you have the option. Nov 1, 2016 at 13:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .