JSON to String Converter - Escape & Unescape JSON
Turn JSON into one escaped string you can paste into code, an env var or an API body, or decode a string back into JSON, with a live tree render view.
- Instant
- 100% Client-Side
- No Login Required
- Data Stays in Your Browser
Options: double quotes · one line
JSON input
Paste JSON. The escaped string updates as you type.
Escaped string
Render view
The structure of your JSON is shown here once the input is valid.
Your JSON stays on this device. Processing happens entirely in your browser.
What escaping changes, character by character
A JSON string literal can hold any text, but a few characters have to be written as escapes so the string still ends where it should. A double quote becomes \", a backslash becomes \\, a line break becomes \n, and a tab becomes \t. Other control characters become \u00XX. Unicode letters and emoji stay as they are, which is valid JSON and keeps Hindi or other scripts readable.
Backslashes are where most mistakes happen. The Windows path C:\temp has one backslash in real life. Written inside JSON it must be "C:\\temp", because a single \t would be read as a tab. Put that JSON inside another string and each of those two backslashes is escaped again, giving four. That is why escaped strings look noisy, and why the Decoded text view is useful: it shows what a program will actually read once it parses the string.
One line or kept line breaks
One line minifies the JSON first, so the string is as short as possible, which suits env vars and request bodies. Kept line breaks formats the JSON with two-space indentation and writes each break as \n, so the string prints readably when logged or shown. Both decode to the same data.
Checking the structure before you ship it
The render view draws the parsed value as a tree, with every key, array item and value type coloured, and counts keys, depth, strings and numbers. Hover a row to see its path, such as $.skills[1]. It is a quick way to confirm that a decoded string really holds the object you expected and not, say, another layer of string.
A worked example: one object, three outputs
Start with this small object. It has a quote inside a value and a line break, the two things that most often break hand-written strings:
{"name": "Ravi \"RK\"", "note": "line one\nline two"}Double quotes, one line gives the form you paste into JSON, Python, Go, Java or an env var. Every inner quote and backslash is escaped once more:
"{\"name\":\"Ravi \\\"RK\\\"\",\"note\":\"line one\\nline two\"}"Single quotes suits JavaScript or PHP code written with single-quoted strings. The double quotes no longer need escaping, so the result is easier to read:
'{"name":"Ravi \\"RK\\"","note":"line one\\nline two"}'No quotes gives the escaped body alone, for templates and config systems that add their own quotes. All three decode back to exactly the same object. Press Swap after converting to check that for yourself.
Where you actually need JSON as a string
- Environment variables. A service account or feature-flag config stored in one variable, such as
GOOGLE_CREDENTIALS, has to be a single line. Use one-line output and paste it between the quotes in your.envfile. - JSON inside JSON. Webhooks, message queues and logging platforms often carry the real payload in a string field. Escape the inner document here, then place it as the value of that field.
- Test fixtures and code. A long JSON response hard-coded in a unit test is easier to keep as one escaped literal than to rebuild with string concatenation.
- Reading logs. Many logs print escaped JSON. Paste the string into String → JSON to get the object back with a tree you can expand.
Why invalid JSON is refused by default
Input like {a:1}or a trailing comma is not JSON, and escaping it would only hide the error until the receiving program fails. The tool stops and shows the parser message instead. If you really want to escape plain text, tick “Allow non-JSON text”.
Escaping is not encryption
An escaped string is the same data written differently. Anyone who sees it can decode it in a second, so an API key inside escaped JSON is exactly as exposed as the plain key. Keep secrets in a secret manager or your hosting provider’s environment settings, not in strings committed to code.
Related JSON tools
To fix a broken payload first, the JSON Formatter and Validator points to the exact line and column of the error. The YAML Converter turns JSON into YAML and back, and the Base64 Converter decodes payloads that arrive base64-encoded.
How to Use
Choose JSON → String to escape JSON, or String → JSON to decode an escaped string.
Paste your input. The output updates as you type.
For JSON → String, pick double quotes, single quotes or no quotes, and one line or kept line breaks.
Open the Render view to check the structure as a tree, or see the decoded text.
Copy the result, or press Swap to run it back the other way and confirm the round trip.
Features
Common Questions
Convert JSON to an escaped string and back. JSON → String turns a JSON object or array into one string literal with double, single or no quotes, on one line or with line breaks kept as \n, ready for code, env vars or a string field in an API body. String → JSON decodes an escaped string, unwrapping double-encoded strings, and the render view shows the result as a collapsible tree with key and depth counts. Everything runs in your browser.
About JSON to String Converter
Turn a JSON object or array into one escaped string you can paste into code, an environment variable, a database text column or a string field inside another API payload, and decode such a string back into JSON. Choose double quotes, single quotes for JavaScript or no quotes, and one line or kept line breaks written as \n. String to JSON unwraps double- and triple-encoded strings and says how many layers it removed. The render view draws the result as a collapsible tree with key, depth, string and number counts, or shows the decoded text a program will actually read. Everything runs in your browser.
Processing Note
JSON to String Converter runs in your browser, so the input you enter is processed locally on this page and is not uploaded to a ToolMintX account.
Tool Limits
IT tools provide quick diagnostics and transformations. They cannot see every private network, deployment setting, proxy, firewall, or production edge case.
Explore More
AI VRAM Calculator
Estimate GPU VRAM for LLM inference and training using model, quantization, users, and context length.
Client-sideAI API Cost Calculator
Compare and estimate AI API costs across OpenAI, Claude, Gemini, DeepSeek and more for text, image, video, and embeddings.
Client-sideAPI Key and .env Secret Generator
Generate secure .env secrets plus selectable Hugging Face, OpenAI, JWT, database, and webhook variables.
Client-sideSubnet Calculator
IPv4 subnet calculator: network and broadcast address, subnet and wildcard mask, usable host range, and host count from any IP and CIDR prefix.
Client-side