Articles in this section

Convert a multiline field value to a single line

When a field value contains newline characters (\n) — like a multiline mailing address — integrator.io renders it across multiple lines by default. You can use Handlebars helpers to escape those newlines and replace them with another character, producing a single-line value. This article shows how, using a shipping address as an example.

Because the field name contains a space, reference it by wrapping it in square brackets: [Shipping Address].

Sample data

{
  "Shipping Address": "Example Name\n1313 Mockingbird Lane\nSan Mateo CA 94404\nUnited States"
}

The field stores newline characters (\n) that integrator.io interprets as line breaks.

Default output renders multiple lines

By default, referencing the field renders the value with its line breaks intact.

{{[Shipping Address]}}

Output:

Example Name
1313 Mockingbird Lane
San Mateo CA 94404
United States

Escape the newline characters with jsonEncode

Use the jsonEncode helper to preserve the newline characters as the literal text \n instead of line breaks.

{{jsonEncode [Shipping Address]}}

Output:

Example Name\n1313 Mockingbird Lane\nSan Mateo CA 94404\nUnited States

Replace the newline characters with replace

Use the replace helper to substitute another value for each escaped newline. This example replaces each \n with a comma and a space (, ), producing a single line.

{{replace (jsonEncode [Shipping Address]) "\n" ", "}}

Output:

Example Name, 1313 Mockingbird Lane, San Mateo CA 94404, United States