Formatter Validator Minifier Escape / Unescape JSON ↔ String JSON ↔ YAML JSON → CSV NDJSON / JSON Lines JSON → Types JSON ↔ XML JSON Diff JSON Patch Canonicalize (RFC 8785) Schema Validator Schema Generator JSONPath Tester JWT Decoder JSON Errors Schemas More Tools
● ESCAPE STRINGS · UNESCAPE LITERALS · 100% BROWSER-BASED

JSON Escape / Unescape

Turn any text into a valid JSON string, or turn an escaped JSON string back into raw text. The escape presets reproduce what each language's serializer actually emits — measured, not guessed — so you can match Go, Python or .NET output exactly.

Input 0 bytes
1
Escaped JSON string
Result will appear here

What each serializer escapes by default

RFC 8259 §7 requires only three things to be escaped: the quotation mark, the reverse solidus, and the control characters U+0000–U+001F. Everything else is a serializer's choice — and they disagree. The table below was produced by running each serializer on the same inputs. Amber means the character was changed.

Serializeré (U+00E9)😀 (U+1F600, astral)< > & (HTML-significant)' (apostrophe)/ (solidus)U+2028 LINE SEPARATORU+007F DELETE
JavaScript · V8 (Node, Chrome)é😀<a>&bit'sa/b(raw)
JavaScript · JavaScriptCore (Safari)é😀<a>&bit'sa/b(raw)
Python · json.dumps() default\u00e9\ud83d\ude00<a>&bit'sa/b\u2028\u007f
Python · ensure_ascii=Falseé😀<a>&bit'sa/b(raw)
Go · encoding/json v1é😀\u003ca\u003e\u0026bit'sa/b\u2028
Go · SetEscapeHTML(false)é😀<a>&bit'sa/b\u2028
Java · Jacksoné😀<a>&bit'sa/b(raw)
Java · Gsoné😀\u003ca\u003e\u0026bit\u0027sa/b\u2028
.NET · System.Text.Json\u00E9\uD83D\uDE00\u003Ca\u003E\u0026bit\u0027sa/b\u2028\u007F
.NET · Newtonsoft.Jsoné😀<a>&bit'sa/b\u2028
PHP · json_encode()\u00e9\ud83d\ude00<a>&bit'sa\/b\u2028
Ruby · JSON.generateé😀<a>&bit'sa/b(raw)

Node.js 22, CPython 3.12, Go 1.22, Java 21 (Jackson 2.14 / Gson 2.10), .NET 8 (System.Text.Json / Newtonsoft.Json 13), PHP 8.3, Ruby 3.2, JavaScriptCore via Bun 1.4.

Three surprises in that table

Go escapes <, > and &

json.Marshal turns them into \u003c, \u003e and \u0026 so JSON can be embedded in HTML without a browser reinterpreting it. Use an Encoder with SetEscapeHTML(false) to stop it. Go's encoding/json/v2 drops this default.

Python and PHP escape all non-ASCII

json.dumps() defaults to ensure_ascii=True, so café becomes caf\u00e9. Pass ensure_ascii=False for UTF-8 output. PHP needs JSON_UNESCAPED_UNICODE, and JSON_UNESCAPED_SLASHES to stop / becoming \/.

Gson and .NET escape the apostrophe

Both turn ' into \u0027. Jackson does not. If you are diffing Gson output against Jackson output byte-for-byte, this is usually why they differ.

What the specification requires

Why the twelve serializers above disagree, and which differences have a security angle: Every JSON serializer escapes differently →

Everything on this page runs in your browser — no upload, no server-side processing. How it works →