Skip to main content
Home Tools JSON Encoder / Decoder
🔐 Encoding & Security ✅ 100% Free ⚡ Instant

JSON Encoder / Decoder

Escape plain text strings for safe inclusion in JSON (converts "\", \\\, newlines → \n), or decode JSON-escaped strings back to their original form.

Plain Text 0 chars
JSON-Safe String 0 chars
Enter text to begin.
📊 Stats
0
Input chars
0
Output chars
📖 JSON Escape Reference
"\"
\\\
newline\n
tab\t
carriage return\r
null byte\u0000

What is JSON String Encoding?

JSON (JavaScript Object Notation) has a strict set of rules for string values. Certain characters must be escaped with a backslash to be valid inside a JSON string: double quotes ("\"), backslashes (\\\), and control characters like newlines (\n), tabs (\t), and carriage returns (\r). This tool handles the escaping and unescaping of these characters.

Frequently Asked Questions

Any time you're building a JSON string manually (concatenating strings rather than using a JSON library like JSON.stringify()), or when you need to embed a multi-line string or a string containing quotes into a JSON value. In practice, always prefer JSON.stringify() in JavaScript — it handles all escaping correctly and handles edge cases you might miss.
JSON encoding escapes special characters within a string so it's valid JSON syntax — the result is still human-readable text. Base64 encoding converts arbitrary binary data to an ASCII-safe format — the result looks like random characters and is ~33% larger. Use JSON escaping when you need a valid JSON string; use Base64 when you need to embed binary data (like images) in JSON.
The JSON specification (RFC 8259) requires that control characters (U+0000 through U+001F) be escaped. These characters include newline, tab, carriage return, and others that would break string parsing if left unescaped. Unescaped control characters make JSON technically invalid and can cause subtle bugs in parsers.
Copied!