{
    "mode": "man",
    "parameter": "jsesc",
    "section": "1",
    "url": "https://www.chedong.com/phpMan.php/man/jsesc/1/json",
    "generated": "2026-08-28T20:21:03Z",
    "synopsis": "jsesc [-s | --single-quotes string]\n[-d | --double-quotes string]\n[-w | --wrap string]\n[-e | --escape-everything string]\n[-6 | --es6 string]\n[-l | --lowercase-hex string]\n[-j | --json string]\n[-p | --object string]\n[-p | --pretty string]\n[-v | --version]\n[-h | --help]",
    "sections": {
        "NAME": {
            "content": "jsesc — escape strings for use in JavaScript string literals\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "jsesc [-s | --single-quotes string]\n[-d | --double-quotes string]\n[-w | --wrap string]\n[-e | --escape-everything string]\n[-6 | --es6 string]\n[-l | --lowercase-hex string]\n[-j | --json string]\n[-p | --object string]\n[-p | --pretty string]\n[-v | --version]\n[-h | --help]\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "jsesc  escapes  strings  for  use in JavaScript string literals while generating the shortest\npossible valid ASCII-only output.\n",
            "subsections": []
        },
        "OPTIONS": {
            "content": "",
            "subsections": [
                {
                    "name": "-s, --single-quotes",
                    "content": "Escape any occurrences of ' in the input string as \\', so that the output can be  used  in  a\nJavaScript string literal wrapped in single quotes.\n",
                    "flag": "-s",
                    "long": "--single-quotes"
                },
                {
                    "name": "-d, --double-quotes",
                    "content": "Escape  any  occurrences  of \" in the input string as \\\", so that the output can be used in a\nJavaScript string literal wrapped in double quotes.\n",
                    "flag": "-d",
                    "long": "--double-quotes"
                },
                {
                    "name": "-w, --wrap",
                    "content": "Make sure the output is a valid JavaScript string literal wrapped  in  quotes.  The  type  of\nquotes can be specified using the -s | --single-quotes or -d | --double-quotes settings.\n",
                    "flag": "-w",
                    "long": "--wrap"
                },
                {
                    "name": "-6, --es6",
                    "content": "Escape any astral Unicode symbols using ECMAScript 6 Unicode code point escape sequences.\n",
                    "flag": "-6",
                    "long": "--es6"
                },
                {
                    "name": "-e, --escape-everything",
                    "content": "Escape all the symbols in the output, even printable ASCII symbols.\n",
                    "flag": "-e",
                    "long": "--escape-everything"
                },
                {
                    "name": "-j, --json",
                    "content": "Make  sure  the output is valid JSON. Hexadecimal character escape sequences and the \\v or \\0\nescape sequences will not be used. Setting this flag enables the -d | --double-quotes and  -w\n| --wrap settings.\n",
                    "flag": "-j",
                    "long": "--json"
                },
                {
                    "name": "-o, --object",
                    "content": "Treat  the input as a JavaScript object rather than a string. Accepted values are flat arrays\ncontaining only string values, and flat objects containing only string values.\n",
                    "flag": "-o",
                    "long": "--object"
                },
                {
                    "name": "-p, --pretty",
                    "content": "Pretty-print the output for objects, using whitespace to make it more readable. Setting  this\nflag enables the\n",
                    "flag": "-p",
                    "long": "--pretty"
                },
                {
                    "name": "-l, --lowercase-hex",
                    "content": "Use  lowercase  for  alphabetical hexadecimal digits in escape sequences.  -o | --object set‐\nting.\n",
                    "flag": "-l",
                    "long": "--lowercase-hex"
                },
                {
                    "name": "-v, --version",
                    "content": "Print jsesc's version.\n",
                    "flag": "-v",
                    "long": "--version"
                },
                {
                    "name": "-h, --help",
                    "content": "Show the help screen.\n",
                    "flag": "-h",
                    "long": "--help"
                }
            ]
        },
        "EXIT STATUS": {
            "content": "The jsesc utility exits with one of the following values:\n\n0     jsesc successfully escaped the given string and printed the result.\n1     jsesc wasn't instructed to escape anything (for example, the --help flag was set);  or,\nan error occurred.\n",
            "subsections": []
        },
        "EXAMPLES": {
            "content": "",
            "subsections": [
                {
                    "name": "jsesc 'foo bar baz'",
                    "content": "Print an escaped version of the given string.\n"
                },
                {
                    "name": "echo 'foo bar baz' | jsesc",
                    "content": "Print an escaped version of the string that gets piped in.\n"
                }
            ]
        },
        "BUGS": {
            "content": "jsesc's bug tracker is located at <https://github.com/mathiasbynens/jsesc/issues>.\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Mathias Bynens <https://mathiasbynens.be/>\n",
            "subsections": []
        },
        "WWW": {
            "content": "<https://mths.be/jsesc>\n\nMay 13, 2016                                    jsesc(1)",
            "subsections": []
        }
    },
    "summary": "jsesc — escape strings for use in JavaScript string literals",
    "flags": [
        {
            "flag": "-s",
            "long": "--single-quotes",
            "arg": null,
            "description": "Escape any occurrences of ' in the input string as \\', so that the output can be used in a JavaScript string literal wrapped in single quotes."
        },
        {
            "flag": "-d",
            "long": "--double-quotes",
            "arg": null,
            "description": "Escape any occurrences of \" in the input string as \\\", so that the output can be used in a JavaScript string literal wrapped in double quotes."
        },
        {
            "flag": "-w",
            "long": "--wrap",
            "arg": null,
            "description": "Make sure the output is a valid JavaScript string literal wrapped in quotes. The type of quotes can be specified using the -s | --single-quotes or -d | --double-quotes settings."
        },
        {
            "flag": "-6",
            "long": "--es6",
            "arg": null,
            "description": "Escape any astral Unicode symbols using ECMAScript 6 Unicode code point escape sequences."
        },
        {
            "flag": "-e",
            "long": "--escape-everything",
            "arg": null,
            "description": "Escape all the symbols in the output, even printable ASCII symbols."
        },
        {
            "flag": "-j",
            "long": "--json",
            "arg": null,
            "description": "Make 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."
        },
        {
            "flag": "-o",
            "long": "--object",
            "arg": null,
            "description": "Treat 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."
        },
        {
            "flag": "-p",
            "long": "--pretty",
            "arg": null,
            "description": "Pretty-print the output for objects, using whitespace to make it more readable. Setting this flag enables the"
        },
        {
            "flag": "-l",
            "long": "--lowercase-hex",
            "arg": null,
            "description": "Use lowercase for alphabetical hexadecimal digits in escape sequences. -o | --object set‐ ting."
        },
        {
            "flag": "-v",
            "long": "--version",
            "arg": null,
            "description": "Print jsesc's version."
        },
        {
            "flag": "-h",
            "long": "--help",
            "arg": null,
            "description": "Show the help screen."
        }
    ],
    "examples": [
        "Print an escaped version of the given string.",
        "Print an escaped version of the string that gets piped in."
    ],
    "see_also": []
}