JSESC(1)
π JSESC(1) π
okay so bestie, listen β jsesc is the little command-line baddie that escapes strings for use in JavaScript string literals. that's the whole vibe. she's giving "shortest possible valid ASCII-only output" and she ate, no cap. β¨
πΈ SYNOPSIS πΈ
jsesc [-s | --single-quotes string]
[-d | --double-quotes string]
[-w | --wrap string]
[-e | --escape-everything string]
[-6 | --es6 string]
[-l | --lowercase-hex string]
[-j | --json string]
[-p | --object string]
[-p | --pretty string]
[-v | --version]
[-h | --help]
π¦ DESCRIPTION π¦
so like, jsesc escapes strings for use in JavaScript string literals while generating the shortest possible valid ASCII-only output. that's it. that's the mission. main character energy fr fr. π
β¨ OPTIONS β¨
-s,--single-quotesβ escapes any occurrences of'in the input string as\', so that the output can be used in a JavaScript string literal wrapped in single quotes. keeping it cozy in single quotes, periodt. π-d,--double-quotesβ escapes any occurrences of"in the input string as\", so that the output can be used in a JavaScript string literal wrapped in double quotes. the double-quote girlies are eating today. π-w,--wrapβ makes sure the output is a valid JavaScript string literal wrapped in quotes. which kind of quotes? you get to pick, using the-s | --single-quotesor-d | --double-quotessettings. choose your fighter. π«Ά-6,--es6β escapes any astral Unicode symbols using ECMAScript 6 Unicode code point escape sequences. astral symbols get the es6 treatment, iconic. π₯-e,--escape-everythingβ escapes all the symbols in the output, even printable ASCII symbols. literally everything, she does not discriminate. π-j,--jsonβ makes sure the output is valid JSON. hexadecimal character escape sequences and the\vor\0escape sequences will not be used. setting this flag enables the-d | --double-quotesand-w | --wrapsettings. json mode: unlocked. β-o,--objectβ treats the input as a JavaScript object rather than a string. accepted values are flat arrays containing only string values, and flat objects containing only string values. flat only bestie, no nesting shenanigans. π-p,--prettyβ pretty-prints the output for objects, using whitespace to make it more readable. setting this flag enables the-l,--lowercase-hexβ uses lowercase for alphabetical hexadecimal digits in escape sequences.-o|--objectsetting.
π okay so ngl, the source manpage text for-p | --prettyand-l | --lowercase-hexis scrambled β the-pdescription cuts off at "enables the" and the-ldescription has the-o | --objectfragment dangling at the end. i'm not fixing it, i'm just telling you, because i keep every detail. iykyk. π
-v,--versionβ printsjsesc's version. vibe check on the version number. π-h,--helpβ shows the help screen. when in doubt, ask for help bestie. π§
π EXIT STATUS π
the jsesc utility exits with one of these values:
0βjsescsuccessfully escaped the given string and printed the result. slay. β¨1βjsescwasn't instructed to escape anything (for example, the--helpflag was set); or, an error occurred. not slay. π
π EXAMPLES π
jsesc 'foo bar baz'β print an escaped version of the given string.echo 'foo bar baz' | jsescβ print an escaped version of the string that gets piped in.
π BUGS π
jsesc's bug tracker is located at <https://github.com/mathiasbynens/jsesc/issues>. found something cursed? take it there bestie, they wanna know. π
π AUTHOR π
Mathias Bynens <https://mathiasbynens.be/> β the icon, the moment, the legend. π
π WWW π
<https://mths.be/jsesc> β go look, go lurk, go be obsessed. π¦
and that's the whole page bestie β written up on May 13, 2016, part of the jsesc(1) manual, so when you're deep in a terminal at 2am escaping strings, just know she's got you. bye mwah πβ¨
π¦ where this page comes from
- debian bookworm: node-jsesc 3.0.2+~3.0.1-1 Β· MIT
- debian trixie: node-jsesc 3.0.2+~3.0.1-1 Β· MIT
- ubuntu jammy: node-jsesc 3.0.2+~3.0.1-1 Β· MIT
- ubuntu noble: node-jsesc 3.0.2+~3.0.1-1 Β· MIT
- ubuntu resolute: node-jsesc 3.0.2+~3.0.1-1 Β· MIT
- ubuntu stonking: node-jsesc 3.1.0+~3.0.3-1 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms