JSON Escape/Unescape

    Convert special characters to escape sequences and back

    Instant Convert

    Escape or unescape with one click

    100% Private

    Runs entirely in your browser

    No Signup

    Free tool, no registration required

    What Is JSON String Escaping?

    JSON string escaping is the process of converting characters that have special meaning inside a JSON string — or that cannot appear literally — into their backslash-prefixed escape sequences. The JSON specification (RFC 8259) requires that double quotes, backslashes, and control characters be escaped within string values. Without escaping, a double quote inside a value would terminate the string prematurely, and an unescaped newline would produce invalid JSON that parsers reject.

    Common Use Cases

    Embedding multi-line text — such as a code snippet, an SQL query, or a Markdown document — into a JSON field requires converting every newline to \n and every tab to \t. When storing JSON inside another JSON string (double-serialization), all inner quotes and backslashes must be escaped. Configuration files that carry file paths with backslashes on Windows need each backslash doubled to \\. API responses that serialize entire JSON documents as string fields also require this full-depth escaping.

    How to Use This Tool

    In "Escape" mode, paste any raw text — including newlines, tabs, quotes, or backslashes — and click Escape. The output is a valid JSON string value, including the surrounding double quotes, ready to paste into a JSON document. In "Unescape" mode, paste a JSON string (with or without the surrounding quotes) to recover the original text. Click Swap to chain the operations: the escaped result feeds back as input with the mode reversed, useful for verifying round-trips.

    Technical Notes

    This tool uses JavaScript's built-in JSON.stringify for escaping, which ensures 100% spec-compliant output. On the unescape side, JSON.parse handles quoted strings, and a manual sequence replacement handles unquoted escaped text. Unicode escape sequences (\uXXXX) are handled transparently by both paths. All conversions run in your browser — no data is transmitted to a server.

    Frequently Asked Questions