JSON stringify text

Turn plain text into a JSON string, escaping its quotes, backslashes and line breaks.

Privacy: runs in your browser

This tool processes your input in this browser. Inputs and results are excluded from analytics. Draft saving is optional and stays on this device; delete saved text with the draft controls. Loading text from a URL is optional and contacts that server; its URL and your IP address are visible to the server. When a button sends your result to another tool, it waits in this tab until that tool opens it, for up to a minute, and is then deleted.

Copy link includes the inputs you choose to share in the address. Anyone with that link can reopen them. Files and generated results are excluded. Password and key tools share settings only.

Options and local file

Optional settings apply only to this tab.

Your result

More
Keyboard shortcuts

Sharing and starting over

A copied link includes what you entered and your settings, so anyone with it can see them. Leave private text out. Files and results are not included; random draws are made again.

Start over puts the tool back to its starting values and closes any open file or device. Drafts you saved stay on this device until you delete them.

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.

Next: JSON unstringifier

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 rely on 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.

Next: JSON formatter

Cite this page

ToolOctopus. “JSON stringify text.” Updated . 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. License and source code.

Find a tool

Type a task, a unit pair, a sum or a time zone. ↓ to choose, Enter to open.