Escape JSON
JSON-escape a string for embedding inside another JSON value or code literal - with or without outer quotes, plus unescape. Free, offline, client-side, instant, secure.
- Runs in your browser
- Nothing uploaded
- Free, no sign-up
Convert a raw string into its JSON-escaped form (" → \",
\ → \\, newlines → \n, control chars → \uXXXX).
Three modes: escape with outer quotes, escape without, or reverse the process.
How to Use Escape JSON
- Pick a mode. "Escape - JSON string literal" wraps the output in
"…"and escapes inner content - paste-ready as a JSON value. "Escape - bare" gives just the escaped characters with no outer quotes - useful when you're already inside a quoted string. "Unescape" reverses either form. - Paste your text. Output updates live (100 ms debounce). Use any input - a whole JSON document, a code snippet, a log line, or text with quotes and newlines.
- Read the stats line. Mode label, input → output character counts, and how many escape sequences were emitted (escape mode) or decoded (unescape mode).
- Errors only happen in unescape mode when the input has a malformed escape (
x, an unterminateduXXX, or a stray backslash). The stats line turns red with the parser's error message. - Copy or download with the buttons. Ctrl/Cmd + Enter copies. Download writes
escaped.json.txt(orunescaped.txtin unescape mode).
Frequently Asked Questions
What is JSON escaping and when do I need it?
JSON escaping converts a string so it can sit inside a JSON string value or be embedded as a code literal. The required escapes per RFC 8259 are: " → ", → \, the C-style control characters b f n r t, and any other character below U+0020 as uXXXX. Use this tool when you have arbitrary text (a quote-containing message, a multi-line log, a source code snippet) and need to put it inside JSON or inside a JS/Python/etc. string literal.
What’s the difference between the two escape modes?
“With outer quotes” gives you a complete JSON string literal – paste it directly as a JSON value ("He said "hi""). “Bare” omits the surrounding quotes – useful when you’re already inside a quoted string (e.g. building a JavaScript template literal: "He said " + bareEscape + " loudly").
Does this validate that my input is valid JSON?
No – and it shouldn’t. The tool treats input as an arbitrary string and produces the escaped form regardless. That’s by design: you might be escaping a snippet of source code, a log entry, or a paragraph of text that isn’t JSON. For JSON validation, use the JSON validator/formatter tool.
How is this different from JSON.stringify?
It’s not – internally the escape modes use JSON.stringify(string), optionally stripping the outer quotes. JSON.stringify on a string does exactly the right thing per RFC 8259. The value the tool adds over typing that in the console is the modes, the live preview, the stats, copy/download, and the unescape direction.
Does unescape work with both quoted and unquoted input?
Yes. If the input starts and ends with ", the tool treats it as a complete JSON string literal and parses it directly. Otherwise it wraps the input in "…" internally before parsing. Either way you get back the decoded plain string.
What happens with control characters or Unicode?
Control characters (U+0000-U+001F) are escaped as b f n r t for the named ones and uXXXX for the rest. Non-ASCII characters (accented letters, emoji, CJK) are not escaped – they pass through verbatim, since JSON is required to be UTF-8 and any modern parser handles them. If you specifically need ASCII-only output, post-process with a Unicode-to-uXXXX converter.
Can I escape huge inputs?
Practically yes. The implementation is one JSON.stringify call – O(n) over the input length. A 1 MB string takes about 50 ms on a 2020 laptop. The 100 ms input debounce means you won’t see lag while typing even on large inputs.
Is my data secure?
Yes. The page loads three static files (HTML, CSS, JS) and then runs entirely in your browser. Your input never leaves the device – no fetch, no XHR, no analytics, no cookies. You can disconnect from the internet after the page loads and the tool still works.
Is this tool free?
Yes – free, unlimited, no signup, no watermark. Use the output anywhere. Attribution to is appreciated but not required.
Related Tools
Analyze JSON Online and Validate JSON Structure →
Analyze JSON Online Validate & Analyze JSON Structure with detailed statistics including depth, key…
Capture JSON Screenshot Generator →
Capture JSON Screenshot and Render pretty-printed JSON as a syntax-highlighted PNG screenshot - dark…
Censor JSON And Redactor →
Censor JSON and Redact passwords, tokens, and PII in JSON with asterisks, [REDACTED], or…
Base64 to JSON Decoder →
Decode Base64 to pretty-printed JSON - URL-safe variant, sort keys, indent 2/4/tab/minified. Free, client-side,…
Convert JSON to Base64 →
Encode JSON to Base64 or decode back. Standard / URL-safe / no padding. Pretty/minified/sorted.…
Convert JSON to Bson →
Real BSON encoding per bsonspec.org - int32/int64/double types, embedded docs, arrays. Bidirectional. Free, offline,…
Convert JSON to Image →
Render JSON as a syntax-highlighted PNG/JPEG with 6 themes, custom fonts, line numbers. Free,…
Convert JSON to Properties →
Convert JSON to Java .properties with real escaping (RFC-correct keys/values). Bidirectional. Spring-style arrays. Free,…
Convert JSON to Text →
Convert JSON to plain text - pretty, dot-path, indented tree, YAML-like, or numbered outline.…
Convert JSON to TSV →
Convert JSON to TSV with real tab/newline escaping. Nested flattening, header union, bidirectional. Free,…
Convert TSV to JSON →
Convert TSV to JSON (and back) with type inference, headers toggle, empty-cell strategy, pretty-print.…
Edit JSON →
Edit a JSON value by dot/bracket path, format or minify, indent 2/4 spaces. Live…