Description
Serialize text using JSON.stringify.
A JSON lexeme is its textual spelling, which differs from the decoded value. Escapes, quotes, raw control characters, and surrounding whitespace must be interpreted in context.
Serialize text using JSON.stringify.
When to use this tool
Use JSON: JSON String Solidus Escape Choice when you need a narrowly defined JSON string or separator diagnostic.
How to use the tool and how it works
- Enter text, escapeSolidus. Use the units and conventions below.
- Run the tool. Correct any format, range, or cross-field input error before interpreting the output.
- Read result. Expand result to inspect the returned fields.
Serialize text using JSON.stringify. When escapeSolidus is true, additionally replace each forward slash with its escaped solidus spelling.1
| Input field | Meaning and units | Accepted input |
|---|---|---|
| text | Text | Required. Text. Implementation limit: 8192 Unicode code points and 16384 UTF-16 code units. |
| escapeSolidus | Escape Solidus | Required. Boolean. |
| Output field | Interpretation | Returned shape |
|---|---|---|
| result | Result | Required. Object. |
| result.jsonString | Json String | Calculated result member: string. |
{
"input": {
"text": "a/b",
"escapeSolidus": true
},
"output": {
"result": {
"jsonString": "\"a\\/b\""
}
}
} Limitations and assumptions
- The two spellings decode to the same text; this option alone is not a complete HTML embedding or script-context safety policy.
- Outputs are nested inside result. Inputs must satisfy both the field types and the cross-field conditions above. Invalid input causes an error; a successful false flag or documented placeholder is a different result.
Alternative or Complementary methods
Parse the entire document when validity matters; a local pattern match cannot establish complete JSON syntax.
References
Similar or alternative tools
- JSON: JSON Key Literal Quotation
Serialize key as a JSON string literal using JSON.stringify and return quotedKey.
- JSON String Control Escape Selector
For control point 0-31, choose the named backspace, tab, newline, form-feed, or carriage-return escape when available; otherwise use a four-digit Unicode escape.