Escape Strings for JavaScript Literals

JSON →
library 1.0.1 ·javascript abandoned
verified May 27, 2026

js-string-escape is a utility package designed to safely escape arbitrary JavaScript strings for inclusion as string literals within generated JavaScript code. Currently at version 1.0.1, the package appears to be stable but has not seen updates in approximately nine years (as of April 2026), indicating an abandoned or long-term unmaintained status. It adheres to ECMAScript 5.1 specifications for string escaping and has been tested across all Unicode code points, ensuring robust handling of diverse character sets. A key differentiation point is its explicit focus on JavaScript string literal safety, in contrast to JSON escaping rules; specifically, it will escape `\'` which is invalid in JSON, and does not restrict control characters as JSON does. This makes it suitable for code generation scenarios where the output needs to be valid JavaScript, but unsuitable for generating JSON.

total hits 13
actors 5 distinct systems
last hit 4d ago AhrefsBot
MetaBot
4
GPTBot
2
Script
1

top countries 🇺🇸 United States · 🇫🇷 France · 🇨🇦 Canada · 🇩🇪 Germany