Escape & Unescape Text — Developer Studio
Convert untrusted text for an exact HTML, XML, JSON, URL or JavaScript string context. Inspect changes, reverse safely and export locally — without sending input to a service.
Text transformation workspace
Input → Convert → Inspect → Copy or DownloadHTML text nodes; entity escaping is not HTML sanitization.
Inspect output · Diff, invisible characters and round trip
Round trip checks the inverse for this input and context only.
Escaped sequences in output
Line-level diff (raw source vs converted)
Inspector symbols and highlighted lines never change copied or downloaded bytes.
Batch files · Local-only, up to 12 UTF-8 text files
Use current context, direction and whole-text/each-line scope for every file. File input stays in memory. One invalid file does not remove successful outputs.
No batch files selected.
Maximum 512 KiB per file, 2 MiB source batch, 4 MiB ZIP output. ZIP includes converted text and a manifest; no original files are overwritten.
Local-first: conversions and text files stay in your browser. Nothing is stored by this tool across reloads. Downloads use UTF-8; formatting a syntax context does not make it safe in every possible destination.
Choose a precise text-encoding context
For ordinary HTML text nodes, escape markup characters before inserting text. For an HTML attribute value, use the correct single- or double-quoted context; neither output validates a URL, an event-handler attribute or CSS. XML text supports only five predefined named entities, unlike HTML5's larger entity table. This tool rejects undefined XML entity names instead of quietly keeping them.
JSON string content versus complete JSON literals
Escaped content omits the enclosing quotation marks; a complete JSON string literal includes them. Both can represent a real newline using the two-character sequence backslash-n. Strict decoding rejects bare quotes, invalid backslash escapes and trailing data instead of silently changing the input.
URL components, path segments and form values
URL component decoding keeps the literal plus sign, while application/x-www-form-urlencoded values decode plus as a space. A path segment escapes slashes, question marks and fragments and must not be confused with a full URL parser. A percent-encoded value is not automatically a safe URL destination.
Batch conversion, UTF-8 and line endings
Open local UTF-8 text or a small set of files, convert the whole string or each line, and download exact converted bytes. Imported CRLF/CR line separators are retained for an untouched file even though the browser textarea displays normalized line breaks. The downloadable ZIP contains converted files and a manifest, not your original file copies. Untrusted HTML and JavaScript are never executed by the converter.
How to use Text Escape & Unescape Tool
- Select a precise context: HTML text/attribute, strict XML, JSON content/literal, URL component/form/path, or a supported JavaScript string literal.
- For JSON, choose escaped content without quotes or a complete double-quoted literal. JavaScript quoted literals use a separate supported escape grammar.
- Convert and review the result. Reusing the output also reverses the direction; malformed escapes produce a visible error.
When to use this tool
Prepare text for an HTML, JSON-string or URL-component context. Choose the destination context explicitly; escaping for one format does not make a value safe in every other format.
Escaping depends on context
HTML escaping changes markup characters into entities; XML permits only five predefined names. URL component encoding differs from HTML form values, where spaces use + and literal plus uses %2B. JSON string syntax escapes quotes, backslashes and control characters. Content mode omits the enclosing quotes; literal mode includes them. JavaScript mode here intentionally uses JSON-compatible double-quoted escapes rather than every JavaScript literal feature.
Worked example
Text containing a newline:
Hello
world
JSON string content: Hello\nworld
Complete JSON literal: "Hello\nworld"
URL component for a+b: a%2Bb Keep a string’s surrounding syntax separate from its content
For an authored exercise, use the words Review complete
followed by a real newline and Save the file
. Choose JSON string content to represent the newline as an escape, or complete JSON literal mode when enclosing quotes are required.
- Choose format and direction before conversion. Do not paste an entire JSON object into a mode intended for one string's content.
- Compare content mode with complete-literal mode and inspect which quotes belong to the representation.
- Unescape using the matching context. A backslash sequence in a file path can be meaningful syntax, so do not repeatedly unescape text without knowing its current representation.
- Copy the result only after reviewing it inside the destination's surrounding syntax.
Authored text exercise, no conversion output supplied. JSON-compatible JavaScript string escaping does not parse arbitrary code or template literals. Escaping is not universal sanitization. Use URL Encoder/Decoder for URI/form distinctions or JSON Formatter for a complete JSON value.
Limits and output checks
Escaping does not make text safe in every HTML, CSS, JavaScript or URL context. This tool is not an HTML sanitizer. It supports a bounded single/double-quoted JavaScript literal grammar but does not execute source code or parse arbitrary template literals. Invalid percent/UTF-8 or JSON escape sequences are rejected.
Reference: JSON string syntax.
Frequently asked questions
Should I include the outer JSON quotes?
Include them only when complete JSON literal mode is selected. Content mode expects the escaped characters between those quotes.
Why does URL decoding keep a plus sign?
URL component decoding uses decodeURIComponent and preserves a literal plus sign. Select Form/query value to interpret + as a space.
Can the result be inserted anywhere in HTML?
No. The correct escaping and allowed values depend on the destination context. Validate the surrounding markup and URL scheme separately.
Escape for the destination context
Choose the supported string or URL mode before transforming text. Select complete-literal mode only when the input includes the enclosing JSON quotes.
Scope of this workflow
Escaping is not universal sanitization. HTML, CSS, JavaScript and URL destinations have different surrounding syntax and allowed-value rules.
URL Encoder & Decoder - URI, Component & Form · All developer tools · Privacy policy · Contact PixelOkay