Diagnostic reference
Unterminated string literal
Why a string fails to close: a missing quote, a newline inside quotes, or smart quotes pasted from a document.
Updated September 12, 2026
Apps Script error
SyntaxError: Unterminated string literal
What it means
A string was opened and never closed on the same line: a missing quote, a newline inside a quoted string, or a smart quote pasted from a document. Use a template literal for multiline text or an escaped newline inside a quoted string. Non-ASCII quotes are not string delimiters and can produce a different syntax error.
Related error messages
- SyntaxError: Invalid or unexpected token
- SyntaxError: string literal contains an unescaped line break
Before and after
See the change before you make it.
function greet() {
const msg = "Hello, world;
Logger.log(msg);
}function greet() {
const msg = "Hello, world";
Logger.log(msg);
}How to fix it
- Close the string with the same straight quote that opened it.
- Use a template literal or an escaped newline when the text needs a line break.
- Check pasted text for smart quotes, which are not JavaScript string delimiters.
What stays with you
- Check text copied from documents for other smart characters.
- myFunction does not change string contents beyond the quotes.