WebToolsPlanet
Developer Tools

JSON Multiline String

Paste multiline text and escape it into a valid JSON string value — or paste an escaped JSON string and unescape it back to readable text.

Last updated: May 21, 2026

Client-Side Processing
Input Data Stays on Device
Instant Local Execution

Find this tool useful? Support the project to keep it free!

Buy me a coffee

What is JSON Multiline String?

JSON strings must be on a single line and have certain characters escaped: double quotes become \", newlines become \n, tabs become \t, backslashes become \\, and non-ASCII characters become \uXXXX sequences. When embedding long SQL queries, HTML templates, code snippets, or multi-paragraph text as a JSON value, this escaping must be done precisely — even a single unescaped newline makes the JSON invalid.

This tool converts in both directions: Escape mode takes raw multiline text and produces a single-line JSON string value you can paste directly into JSON. Unescape mode takes an escaped JSON string value and restores the original readable text with real newlines and characters.

How to Use JSON Multiline String

1

Choose Escape (text → JSON string) or Unescape (JSON string → text)

2

Paste your input into the text area or click "Load Sample"

3

The output updates instantly

4

Copy the result and paste it into your JSON or code

Common Use Cases

  • Developers embedding multi-line SQL queries as JSON string values in config files or API payloads.
  • Engineers storing HTML templates or email bodies as JSON string properties in configuration.
  • Developers embedding code snippets in JSON data files for documentation or test fixtures.
  • API developers encoding multi-paragraph text or markdown content as a single JSON string.
  • Teams debugging escaped JSON strings from logs by unescaping them to readable text.
  • Developers embedding shell scripts or command strings in JSON configuration objects.

Example Input and Output

A multiline SQL query is escaped into a single valid JSON string value.

Multiline text
SELECT id, name, email
FROM users
WHERE active = true
  AND created_at > '2024-01-01'
ORDER BY name ASC;
Escaped JSON string value
SELECT id, name, email\nFROM users\nWHERE active = true\n  AND created_at > '2024-01-01'\nORDER BY name ASC;

Privacy

All processing runs in your browser. No data is uploaded to any server.

Using in JSON5 or YAML

JSON5 supports multi-line strings with backslash line continuation, and YAML supports literal block scalars (|) that preserve newlines. If you control the format, consider using those instead of escaping — they are more readable.

Frequently Asked Questions

What characters get escaped?
Newlines (\n), carriage returns (\r), tabs (\t), double quotes (\"), backslashes (\\), and control characters. Unicode characters outside ASCII are escaped as \uXXXX sequences when needed.
Does the output include the surrounding double quotes?
No — the output is the content of the JSON string, without the outer quotes. This lets you paste it directly between the quotes in your JSON: "query": "<paste here>".
What is Unescape mode for?
Unescape takes a JSON string value (with escape sequences like \n and \t) and converts it back to real characters — newlines, tabs, and so on. Useful for reading escaped strings from logs or API responses.
Can I use this for embedding code in JSON?
Yes. Paste your code (JavaScript, Python, SQL, shell, etc.) into Escape mode to get a JSON-safe single-line string. The output is ready to use as a property value in any JSON document.
Is my text sent to a server?
No. All escaping and unescaping runs in your browser using JSON.stringify and JSON.parse. Your text never leaves your device.