Get to know MDN better
The JavaScript error "string literal contains an unescaped line break" occurs when there is an unterminated string literal somewhere. String literals must be enclosed by single (') or double (") quotes and cannot split across multiple lines.
There is an unterminated string literal somewhere. String literals must be enclosed by single (') or double (") quotes. JavaScript makes no distinction between single-quoted strings and double-quoted strings. Escape sequences work in strings created with either single or double quotes. To fix this error, check if:
You can't split a string across multiple lines like this in JavaScript:
Instead, use the + operator, a backslash, or template literals. The + operator variant looks like this:
Or you can use the backslash character ("\") at the end of each line to indicate that the string will continue on the next line. Make sure there is no space or any other character after the backslash (except for a line break), or as an indent; otherwise it will not work. That form looks like this:
Another possibility is to use template literals.
This page was last modified on Jul 8, 2025 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.