JSON has no multi-line string syntax
Python has triple quotes. YAML has | block scalars. JavaScript has backticks. JSON has none of these. The spec (RFC 8259, section 7) forbids raw control characters between quotes, so a pasted paragraph breaks the parser on its first line break.
{
"footer": "Toolexe
Free developer tools"
}
{
"footer": "Toolexe\nFree developer tools"
}
The converter above writes the second form for you. Paste the text with real line breaks, pick a shape, copy the result into your file.
What each character turns into
JSON.stringify follows these rules. The tally strip in the converter counts each row for your text, so you see at a glance whether a Windows file slipped \r characters into the value.
| In your text | In the JSON string | Note |
|---|---|---|
| Line break (LF) | \n | The main reason this page exists. |
| Carriage return (CR) | \r | Comes from files saved on Windows. Usually unwanted. |
| Tab | \t | Indentation survives the round trip exactly. |
| Double quote | \" | Single quotes stay as they are. |
| Backslash | \\ | Windows paths double in length: C:\\logs. |
| Other control characters | \u0000 to \u001f | Rare in text, common in pasted terminal output. |
| U+2028, U+2029 | \u2028, \u2029 | Valid raw in JSON, fatal in older JavaScript. Always escaped here. |
| Accents, emoji | Unchanged | Tick ASCII only to write \u00e9 style escapes instead. |
Three shapes for long text, ranked
1. Escaped string
One value, one line. Programs read the text back with no extra step. A certificate in "tlsCert", an email template, a migration query. Hard to edit by hand once the text grows past a few lines.
Best default for machine-written files.
2. Array of lines
Each line becomes one array item. A reviewer sees a one-line change as one changed row in git. The reading code joins the items with "\n", a step people forget.
Best for config files people edit, such as VS Code snippets.
3. Base64
Encode the bytes, store one opaque string. Safe for binary data plus text with mixed encodings. Unreadable in review, 33 percent larger.
Only for binary content. Not offered here on purpose.
Worked example: a PEM certificate in a deploy config
A deploy file for staging.toolexe.com needs the TLS certificate inline. The certificate runs 30 lines, Base64 rows between two marker lines.
- Open the
.pemfile, copy everything from-----BEGIN CERTIFICATE-----to the end marker. - Paste into the box above with Text to JSON selected.
- Pick Key-value pair, type
tlsCertas the key, keep Line endings on LF. - Check the tally. Expect 29 or 30 under
\nplus zero under\r. LF mode drops Windows carriage returns before escaping. - Copy the line into the config object, then validate the whole file in the JSON Beautifier.
Going the other way, paste "tlsCert": "-----BEGIN..." with JSON to text selected. The converter strips the key, decodes the escapes, plus shows the original 30 lines ready to save as a file.
Where conversions go wrong
Escaping twice
Paste an already escaped string into Text to JSON plus every \n becomes \\n. The receiving program then prints a literal backslash-n instead of a line break. If the tally shows a high \\ count on text without Windows paths, switch direction.
CRLF sneaking into values
Text copied from Notepad or a Windows checkout carries \r\n. Most Unix tools show the stray \r as ^M or break shell scripts with bad interpreter. LF is the default here for this reason. Choose Keep only when you need a byte-exact copy.
Trailing whitespace
Markdown treats two trailing spaces as a hard line break. Trim trailing spaces removes them, so leave the box empty for Markdown content.
When this is the wrong tool
If people hand-edit the file every week, a 40-line escaped string becomes a source of mistakes. Move the text to its own file plus store a path in JSON, or switch the config to YAML where a | block keeps line breaks readable. The JSON to YAML converter handles the move.
To embed a whole JSON object as a string, use JSON Stringify. The page parses the object first, which catches syntax errors this converter treats as plain text.
Everything runs in your browser. Inputs of a few megabytes convert without delay on a laptop. Past about 20 MB the textarea itself slows down before the conversion does.