JavaScript Eval Decode
Paste JavaScript beginning with eval(function(...)) to see the string returned by its inner function, formatted as readable code. Do not use untrusted scripts: decoding can execute JavaScript in your browser.
Eval JavaScript Decoder Tool
JavaScript Eval Decode Formula
Where:
- \(S\) — the text entered in Obfuscated JavaScript Code.
- \(S_{4:}\) — that text after its first four characters, typically removing
eval. - \(E\) — JavaScript evaluation of the remaining expression.
- \(L\) — removal of leading whitespace from the returned string.
- \(B_4\) — formatting with an indentation setting of 4; \(D\) is the displayed result.
This describes the tool’s processing steps, not a special JavaScript decoding function. Evaluation must return a string for the following whitespace-removal and formatting steps to work.
JavaScript Eval Decode – Calculation Example
Example: enter eval(function(p){return p.replace("0", "42");}("const answer = 0;")) in Obfuscated JavaScript Code. Removing eval leaves a function call that returns a string.
\[ \operatorname{replace}(\text{"const answer = 0;"},\text{"0"},\text{"42"})=\text{"const answer = 42;"} \]
Result: Decoded JavaScript Code displays const answer = 42;. This example demonstrates the processing steps; packed scripts usually use a more elaborate replacement function.
How to use the calculator
- Paste the complete expression into Obfuscated JavaScript Code. The intended input starts with
eval(function(...)); keep the function call and its arguments intact. - Run the calculator and read Decoded JavaScript Code. The tool removes the first four characters, evaluates what remains, trims leading whitespace from the returned string, and formats it.
- Use the result’s copy option if you want to inspect the text in an editor. Review what it does before running it elsewhere.
There are no default code values to submit. An empty field produces an “Enter code” message. If the input is malformed or does not return a string, the calculation may instead fail to produce a decoded result.
What JavaScript eval decoding means
Some JavaScript packers produce an outer expression shaped like eval(function(...){...}(...)). The inner function builds a source-code string by replacing short tokens with longer identifiers or other text. In the original expression, the outer eval would then run that generated source. This calculator removes the literal eval prefix so it can display the string returned by the inner expression instead.
That distinction matters when reading the result. The displayed text is the generated source, not necessarily a record of everything that happened during decoding. The inner expression is still evaluated to obtain it, and an inner function can perform actions before it returns a string. Formatting makes the output easier to scan, but it does not explain the code’s behavior or establish that it is safe.
Use the output to check variables, function calls, URLs, and string-building logic more closely. If the source is simply minified rather than wrapped in a compatible eval expression, a JavaScript Compress result illustrates a different kind of transformation: shortening code does not by itself imply an eval-based decoding step. To compare how this style of wrapper is created, see the JavaScript Obfuscator (eval).
Assumptions, limitations, and safety
Do not treat this as a safe malware sandbox. The tool calls JavaScript eval on the input after removing its first four characters. Although that can avoid executing the generated source as the original outer eval would, the remaining expression itself can execute JavaScript. Untrusted input could have side effects in your browser. Inspect suspicious scripts in an appropriate isolated environment instead of pasting them into a page you rely on.
The tool removes exactly four characters; it does not parse JavaScript to locate an outer eval. A leading comment, spaces before eval, or a different wrapper can change what gets evaluated. It also assumes the evaluated expression returns a string: a number, object, or undefined value cannot be processed by the subsequent string operation. The provided logic performs one evaluation and one formatting pass; it does not repeatedly unpack nested layers or provide syntax highlighting.
Formatting may add line breaks and indentation, so the displayed result should not be treated as byte-for-byte identical to the returned string. If inspection reveals a separately Base64-encoded value, a Base64 Decoder may help examine that value; it is not part of this calculator’s decoding process.
Frequently Asked Questions
How can I unpack an eval-packed script without running it?
You can unpack a simple script by tracing its string substitutions by hand. Identify the encoded text, the token list, and the loop that replaces tokens, then apply those replacements to a copy of the text. For more complex scripts, use a static-analysis tool or an isolated environment. Do not assume that removing the outer eval makes the remaining expression safe to run.
Why does the decoder show an error or no useful output?
The input may not match the expected wrapper, or its inner expression may return something other than a string. Check for characters before eval, missing parentheses, and copied text that contains an incomplete function call. Browser restrictions or an exception inside the expression can also interrupt decoding. A blank-looking result may simply mean the returned string contains only whitespace.
Can this tool decode multiple layers of obfuscation?
No, it displays the string produced by one compatible wrapper. If that string contains another packed expression, it remains a separate layer requiring inspection. Do not automatically feed each layer back into the calculator: every evaluation can run code, including code that changes page data or makes network requests. Use an isolated analysis environment for scripts you do not trust.
Is decoded JavaScript the same as the code that ran on the original page?
Not necessarily. The displayed string is source text generated by the wrapper; the original outer eval would attempt to execute that text afterward. The wrapper itself may also have performed actions while constructing the string. To understand the original page’s behavior, examine both the wrapper and the generated code, along with any other scripts and browser APIs they depend on.
Why do I still see unreadable strings after decoding?
Eval packing may be only one obfuscation layer. The generated code can still contain hexadecimal escapes, character-code conversions, encoded data, shortened names, or strings assembled at runtime. Formatting can reveal the structure but cannot turn every encoded value into plain language. Inspect how each string is constructed and used before treating a visible URL or identifier as the full picture.
Does the formatting change how the decoded JavaScript works?
Formatting is intended to make the source easier to read, not to verify its behavior. Usually, added indentation and line breaks preserve JavaScript syntax, but layout changes can matter in edge cases such as automatic semicolon insertion or strings and comments. Keep the original output for comparison, and do not assume that a formatted copy is safe or functionally identical without checking it.
3 thoughts on “JavaScript Eval Decode”