Whatever message this page gives is out now! Go check it out!

JSStringFormat

Last update:
May 18, 2026

Description

Escapes special JavaScript characters, such as single-quotation mark, double-quotation mark, and newline.

Returns

A string that is safe to use with JavaScript.

Category

Syntax

JSStringFormat(string)

Parameters

Parameter
Description
string
A string or a variable that contains one.

Usage

Escapes special JavaScript characters, so you can put arbitrary strings safely into JavaScript.

Example

<cfscript>
    stringValue = "An example string value with a tab chr(8), 
a newline (chr10) and some ""quoted"" 'text'"
    jsStringValue = JSStringFormat(#stringValue#)
    writeOutput(jsStringValue) // An example string value with a tab chr(8), \na newline (chr10) and some \"quoted\" \'text\'
</cfscript>
Output
An example string value with a tab chr(8), \na newline (chr10) and some \"quoted\" \'text\'

Share this page

Was this page helpful?
We're glad. Tell us how this page helped.
We're sorry. Can you tell us what didn't work for you?
Thank you for your feedback. Your response will help improve this page.

On this page