JSON String Escape & Unescape
Escape a JSON, XML, YAML, TOML or TOON document for embedding, or read one back. Free, and runs entirely in your browser — nothing is uploaded.
About String Escaper
Wraps a whole document up as a string so it can live inside another one: a JSON payload embedded in a webhook fixture, an XML template stored in a config value, a manifest carried in an environment variable. Pick how it is carried — a JSON string, XML text or a CDATA section, or a YAML block scalar — and the escaping follows that format's rules.
The reverse direction is the one you reach for more often: paste the escaped blob out of a log or a config file and get the document back, formatted and confirmed to parse. Escaping checks the document first and unescaping checks the result, so neither direction quietly hands you something broken.
Where it helps
- Five carriers covering where documents actually get embedded: JSON strings, XML text, CDATA, and YAML block scalars.
- Escaping parses the document first, so a broken snippet is caught before it is buried inside another file.
- Unescaping parses the result, so you know the blob you recovered is a whole document rather than a truncated one.
- Runs locally, which matters because escaped payloads are usually real traffic.
Limits
- Escaping does not compact the document; run it through the Minifier first if the embedded string needs to be small.
- A JSON string without quotes is convenient for pasting between existing quotes, but it is not valid JSON on its own.
- YAML block scalars depend on indentation, so the output has to keep the indent it was given when it is pasted into a deeper key.
- It escapes whole documents, not a single value inside one — for that, escape the value by hand or edit it in the Structure Formatter first.
Frequently asked questions
Which carrier should I choose?
JSON string for a JSON field or an environment variable, CDATA for markup inside XML, and a YAML block scalar for a manifest that has to stay readable in the file that holds it.
What is the difference between the two JSON options?
One gives you the complete literal with its surrounding quotes; the other gives the escaped contents only, for pasting between quotes that already exist.
Why does unescaping refuse my string?
Usually an unescaped quote or a stray backslash — a fragment copied out of a log without its closing quote does it most often. The message says which.
Can I escape a document that does not parse?
No, and deliberately: an embedded document is hard to inspect later, so a broken one is caught here rather than in whatever consumes it.
Related tools
- Structure Minifier — Strip formatting from JSON, XML, YAML, TOML or TOON
- Structure Formatter — Pretty-print JSON, XML, YAML, TOML, TOON or HCL with a chosen indent
- Structure Validator — Check JSON, XML, YAML, TOML, TOON or HCL and report structural problems
- Base64 — Encode or decode UTF-8 text and URL-safe Base64
- Structure Converter — Convert between JSON, XML, YAML, TOML, TOON, HCL and CSV
- Tree Viewer — Explore JSON, XML, YAML, TOML, TOON or HCL as a collapsible tree
More Structured Formats tools
- Structure Converter — Convert between JSON, XML, YAML, TOML, TOON, HCL and CSV
- Structure Formatter — Pretty-print JSON, XML, YAML, TOML, TOON or HCL with a chosen indent
- Structure Validator — Check JSON, XML, YAML, TOML, TOON or HCL and report structural problems
- Tree Viewer — Explore JSON, XML, YAML, TOML, TOON or HCL as a collapsible tree
- Code Generator — Turn a JSON, YAML, XML or other document into TypeScript, Go, C#, Python, Rust and more
- Schema Generator — Write a JSON Schema, XSD, Avro schema or .proto from a document you already have
- Schema Validator — Check a document against a JSON Schema, .proto, Avro schema, XSD or RELAX NG
- Table Viewer — Show the records in a JSON, XML, YAML, TOML or TOON document as a table
- Structure Compare — Diff two JSON, XML, YAML, TOML, TOON or HCL documents by path
- Structure Repair — Fix broken JSON, YAML, XML, TOML, TOON, INI, .env, .properties and HCL, listing every repair
- Structure Minifier — Strip formatting from JSON, XML, YAML, TOML or TOON
- Path Finder — Select nodes with JSONPath or XPath
- Protobuf & Avro Decoder — Read protobuf wire bytes and Avro container files without their schema
- Expression Evaluator — Reduce a JSONPath or XPath match to a single answer