Updated
JSON stringify text explained
Wrap plain text in a JSON string and escape quotation marks, backslashes and control characters. The output is parsed back and compared with the original before export.
A worked example
A two-line input containing a then b becomes "a\nb" as a JSON string. The visible backslash-n represents the original line break.
Before you use the result
This wraps text as one string. It does not format an object or execute JavaScript. Unicode characters are kept as text rather than unnecessarily escaped.
Cite this page
ToolOctopus. “JSON stringify text.” Updated 2026-09-20. https://tooloctopus.com/json-stringify-text.
Add an access date if your instructions require one.
Citation formatting uses citeproc-js by Frank Bennett and Citation Style Language styles. Licence and source code.
