JavaScript 난독화 도구(기본)
변수 이름 변경, 문자열 인코딩, 공백 제거 등 JavaScript 코드에 기본 난독화 변환을 적용하세요.
이 도구에 대해
JavaScript 난독화의 작동 방식을 서버 없이 브라우저에서 직접 변환을 적용하여 학습하세요. 변수 이름 변경, 문자열 리터럴을 16진수/유니코드 이스케이프로 인코딩, 주석 및 공백 제거, 선택적으로 eval 호출로 출력 래핑 등을 위해 낮음, 중간 또는 높음 난독화 수준 중 선택하세요. 디난독화 탭은 기본 난독화를 되돌리려 시도하므로 전후를 비교할 수 있습니다.
사용 방법
- 1 왼쪽 패널에 JavaScript 코드를 붙여 넣으세요.
- 2 난독화 수준을 선택하세요: 낮음(공백/주석만), 중간(+ 변수 이름 변경), 높음(+ 문자열 인코딩 + eval 래핑).
- 3 '난독화'를 클릭하여 오른쪽 패널에서 변환된 출력을 확인하세요.
- 4 '디난독화' 탭으로 전환하여 난독화된 코드를 붙여 넣고 읽기 가능한 버전 복구를 시도하세요.
What obfuscation is — and what it isn't
Obfuscation makes source code hard for a human to read while keeping it functionally identical for the machine. It is not encryption and it is not security: anything the browser can run, a browser can also show you. This tool exists to teach how the common transformations work by letting you apply them and immediately reverse them. The warning at the top is the honest truth — obfuscated JavaScript can always be recovered, because the engine that executes it has full access to the real code. Treat this as a learning lab, not a vault.
The three levels, transformation by transformation
The tool stacks transformations as you raise the level, so each level includes everything below it:
- Low — strip comments and whitespace. Single-line (
//) and block (/* */) comments are removed and runs of whitespace collapse to single spaces. This is essentially minification: smaller and less readable, but every name is intact. - Medium — rename identifiers. On top of minifying, your variable and function names are replaced with short generated tokens like
_a,_b,_c. A reserved-word list protects language keywords and built-ins (console,Math,JSON,Object, and so on) so the code keeps working. - High — encode strings and wrap in eval. Every string literal's characters become
\xNNhex or\uNNNNunicode escapes, so a readable message like"Hello"turns into"\x48\x65\x6c\x6c\x6f". The whole result is then base64-encoded and wrapped ineval(decodeURIComponent(escape(atob("...")))), hiding the structure behind a single decode-and-run call.
A worked example
Start with the factorial sample the tool loads by default:
function factorial(n) { if (n <= 1) return 1; return n * factorial(n - 1); }
At Medium, the comment vanishes, whitespace collapses, and the names change. factorial and n become tokens like _a and _b, producing something close to function _a(_b){if(_b<=1)return 1;return _b*_a(_b-1)}. The logic is untouched — call it with 10 and you still get 3,628,800 — but the intent is muddier. At High, the string in the console.log line becomes hex escapes and the entire function disappears into one long eval(atob(...)) line. The tool also reports the size change, e.g. 240 → 156 chars (-35.0%), so you can see minification shrinking the code while string-encoding later grows it back.
The deobfuscator, and why names can't come back
The second tab reverses the mechanical steps: it un-escapes \xNN and \uNNNN sequences back into characters, detects the eval(atob(...)) wrapper and decodes the base64 payload, then re-indents by adding newlines after ;, {, and }. What it cannot do is restore original names: once customerEmailAddress has become _d, the meaningful name is gone forever and no tool can guess it back. This asymmetry is the key lesson — string encoding and eval-wrapping are fully reversible, but renaming is lossy. Real-world minifiers exploit the same one-way property to shrink production bundles.
Legitimate reasons to use this
- Understanding minified libraries. Paste a chunk of a minified script into the deobfuscator to make it readable enough to study or debug.
- Learning what attackers' code looks like. Malicious scripts often hide behind
eval(atob(...)); decoding the payload reveals what it actually does. - Light deterrence. Renaming raises the effort to casually copy your client-side logic — useful against the laziest copying, nothing more.
- Teaching. Toggling levels side-by-side is a clear way to show students the difference between minification and obfuscation.
Obfuscation versus minification
It's worth separating two ideas that overlap here. Minification exists to make code smaller and faster to download — it strips comments and whitespace and shortens names, and it's a standard production build step. Obfuscation exists to make code harder to understand — string encoding and eval-wrapping add nothing to performance and actually grow the file, trading size for confusion. The Low level here is essentially minification; the High level is pure obfuscation. In real projects you almost always want minification (smaller bundles) and almost never want client-side obfuscation (it's reversible and slows the parser), which is exactly the lesson this side-by-side comparison makes visible.
Important limitations and a privacy note
The renamer uses naive pattern matching, not a real JavaScript parser, so it can occasionally rename something it shouldn't or miss an edge case — always test obfuscated output before relying on it. For genuine intellectual-property protection, client-side obfuscation is the wrong tool entirely: keep secret logic on a server you control, enforce licensing server-side, or compile to WebAssembly. On privacy, the tool runs completely in your browser — your pasted code is never uploaded — so you can safely experiment, even with code disconnected from the network.