# How to create a multi-line string in JavaScript

By Atta Ur Rehman Shah (https://attacomsian.com/about). Published Jun 19, 2021. Topics: JavaScript.
Canonical URL: https://attacomsian.com/blog/javascript-multiline-strings

> A quick guide to learn how to create a multi-line string in JavaScript.

To create a multi-line string in JavaScript, you can use [template literals](https://attacomsian.com/blog/javascript-template-literals). Template literals were introduced in ES6 and provide a modern way to work with strings.

Unlike regular strings that use a single/double quote as a delimiter, template-literal strings are delimited by the backtick (`` ` ``) character.

Template literals have many features like variable interpolation, tagged templates, to name a few, but most importantly, they can be multi-line.

```javascript
const multiStr = `
    Hey there!
    How are you?
    Do you 
    have 
    time
    for a
    quick 
    call?
`;
```

Before ES6, you have to manually append a newline character (`\n`) to create a multi-line string:

```javascript
var multiStr = 'This is \n\
an example of \n\
multi-line string';
```

Note that the backslash (`\`) placed after the newline character (`\n`) at the end of each line tells the JavaScript engine that the string will continue to the subsequent line. This is necessary to avoid automatic semicolon insertion by the JavaScript engine.
