Skip to content
Grammar
ECMAScript
Deadline
2,000 ms
Runtime
Browser

Escape text as a JavaScript string literal

Encode text as one quoted JavaScript literal without parsing or executing it.

Local processingNo sign-upNever executed

Input

Line breaks, tabs, quotes, backslashes, and Unicode are accepted.

Local

JavaScript string literal

Submit the example or replace it with your own input. Source is parsed but never executed.

What this tool proves

Explicit static behavior

The encoder escapes the selected quote, backslashes, control characters, line separators, and lone UTF-16 surrogates while preserving valid surrogate pairs.

Literal encoding is text processing, not evaluation

The encoder escapes the selected quote, backslashes, control characters, line separators, and lone UTF-16 surrogates while preserving valid surrogate pairs.

This is a direct character encoder. It never decodes by evaluation and its output can be checked by a parser as syntax.

Static analysis has a deliberate safety boundary

Tool Swim parses source as standard ECMAScript inside a disposable Web Worker with a 2,000 ms deadline. It never calls eval, Function, imported modules, or user code.

Source and results stay in the current browser tab. The public tool makes no API request, stores no preset, and does not require an account or telemetry.

Primary references

Questions and answers

Related JavaScript tools