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-quotes or -d | --double-quotes settings. 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 \v or \0 escape sequences will not be used. setting this flag enables the -d | --double-quotes and -w | --wrap settings. 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 | --object setting.
πŸ’€ okay so ngl, the source manpage text for -p | --pretty and -l | --lowercase-hex is scrambled β€” the -p description cuts off at "enables the" and the -l description has the -o | --object fragment dangling at the end. i'm not fixing it, i'm just telling you, because i keep every detail. iykyk. πŸ™ˆ
  • -v, --version β€” prints jsesc'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 β€” jsesc successfully escaped the given string and printed the result. slay. ✨
  • 1 β€” jsesc wasn't instructed to escape anything (for example, the --help flag 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