JavaScript Obfuscator
Renamed, Encoded, Still Running
A JavaScript obfuscator will change a program’s name to make it meaningless and will change its structure so that the way it is written does not give clues about how it works. You can choose from many different types of transformations, use the name prefix that you want to use, and the obfuscator will check that the resulting program is syntactically correct. All of the programs that you enter into this tool are processed on your computer (browser).
- FreePrice
- 4Transforms
- NeverRuns code
- NoneUploads
JavaScript Obfuscator
Paste your code or drop your files — nothing is uploaded
Obfuscated result
- Original
- —
- Obfuscated
- —
- Size change
- —
- Names renamed
- —
- Strings hidden
- —
- Took
- —
Ready. Paste your JavaScript, then press Obfuscate.
Obfuscation is not encryption
Scrambled code takes longer to read, yet a patient person can still follow it. So keep passwords, API keys and other secrets out of any script that runs in a browser, scrambled or not.
What This JavaScript Obfuscator Does
Source code gives both what a program does and how it accomplishes this. So, when someone reads your source code they will understand why you did things the way you did.
An Obfuscator keeps the function and loses the identifiers, string values, and numeric values.
The renamer operates based upon the syntax tree and not on the text itself. The syntax tree has info about each identifier (i.e., whether it represents a variable or property), so the renamer can perform operations on a scope-by-scope basis, as opposed to operating globally.
Four transforms sit behind one editor, and each one is a checkbox. So you can rename a program on its own, or run all of them for a much harder read.
Your code will never run on our servers nor will it ever be sent back to you. So, since we only read and translate your module, there is no difference between your private/confidential program and one available to anyone.
How A JavaScript Obfuscator Rewrites A Script
A first pass generates the same syntax tree that a validation pass would create. The rules used to generate this tree are specified by ECMA-262, and as such, the tree generated is identical to that created by a JavaScript engine.
The renamer takes each of the scopes from the tree in sequence. Each of these scopes (a parameter, a local variable, a function name, or a class name) is assigned an entirely different name (a new opaque name). This new name is generated from a pool of possible names which cannot overlap with any other name now being used.
Two things are left untouched on purpose. A property of an object is not a variable, so obj.userName keeps its spelling. A name that reaches beyond the module, such as an exported name or a global the page calls, is kept too, unless you turn top-level renaming on.
Each pass produces its own tree rather than editing the text. The writer only runs at the end, so a program that fails to parse never gets half rewritten.
The final phase of processing will again parse the generated output. The obfuscator parses its own output before displaying it to the user. As such, if a previous processing step results in non-compliant code, the original file is returned to the user.
The Four Transforms, In The Order They Run
The renaming process is what occurs first. All variables, local parameters, function names, and class names will be converted into short, unreadable strings (e.g., _0x1a2b). Each of these will be given a scope, so it’s possible for two separate functions to have the exact same variable name. As long as you don’t request that they be changed as well, all exported and top-level names will remain untouched.
The string pass comes next. The string literals will move into one single array at the top and each time they’re used, they’ll be looked up by its index in the array using a short accessor function. When the string literals have moved from their positions in front of the code which uses them, searching for messages doesn’t find any useful info.
Number encoding follows. Every plain integer is printed as hexadecimal, so 1000 becomes 0x3e8. The value does not change; the digits just stop reading as a familiar figure.
In order for the module to be compact, it goes through a minification process that removes both the comment lines and spaces in each line. As a result, when this process is complete, you will have a single large block of code instead of many smaller blocks of code.
What Obfuscation Cannot Do
It will not make your code completely unreadable to an individual who wishes to read it. All transforms listed here are, at least in theory, reversible; there are tools available to reverse almost all of them.

The use of a secret key embedded in a script running in a web browser will not maintain the secrecy of the key. Any user able to access the page containing the script can view the key. Since obfuscating the key will increase the difficulty of accessing the key, the key should reside on the server side.
Obfuscation does not prevent people from copying your code. People can always save the code after being rewritten, then serve the code and run the code. License and Contract are the two items that address this issue. Neither License nor Contract are part of the building process.
It does not make a module faster, and it can make it slower. Because the string lookups cost a little work at runtime, the trade is readability for a few milliseconds.
Neither will it prevent someone from seeing your script that is hosted on your server. Anyone who has physical or logical access to the machine will have the same script file, regardless of what the user’s browser download.
The Name Prefix And Keeping The Output Valid
The only other setting on the page is the Name Prefix, which prevents collisions. If you have two different generators that each produce a helper named "a" or "b," then there would be a conflict with a globally accessible variable in the same scope. So, if you use a unique prefix (like _0x) for each generator, you won’t experience this issue.

Top level renaming is still disabled. When you paste in a typical module, such as a top level function that will become a property of window and called from another file through name, if you were to rename it at this point, you would cause problems for the caller that the obfuscator cannot find.
Inside a module or an IIFE nothing outside can reach those names, so turning top-level renaming on there is safe and hides far more.
The end of every run is followed by a parse of its own output. When the obfuscator reads its own result before presenting it, it will report on a transformation which generated an invalid program, as opposed to providing you with the resulting program.
Watch the JavaScript Obfuscator in Action
This brief video shows each step from start to finish. Choose your language below, and switch on captions if they help.
Obfuscating JavaScript In Four Steps
Just four steps, and you never need an account.
Paste the module
A full file can be pasted or a single module. The reader will create a syntax tree, so it is necessary to first compile any extensions like JSX or type annotations before creating the syntax tree.
Tick the transforms
Pick the passes you want to run. The two safest options are local variable renaming and string hiding. If you want to use the names in this file from elsewhere, then don’t select top-level renaming.
Set the name prefix
Give each of the newly created names a unique, short identifier like _0x. By doing this, none of the variables used globally in your application can conflict with the ones you have created as helpers.
Compare the size, then run a test
Finally, read the size row and copy the output. After that, run it on a real page, because only the program doing its job proves a rename safe.
Reasons To Use This JavaScript Obfuscator
Five reasons, and each one is about the read rather than the lock.
The rename works per scope
Because the renamer is based upon the syntax tree, two functions can both have the same short name, but they won’t conflict with each other. This results in the large file coming out of the renamer smaller and working properly, instead of being broken.
Every pass is optional
The use of four checkboxes instead of one button allows you to change the name of a module individually. Changing the name of a module is both the lowest risk way to alter a module and gives most of the advantages.
The obfuscator parses its own output again
Since the last step reads its own output, it produces an invalid code representation of a transform. This means you will catch a broken build at this point, instead of seeing an error message in your browser’s console.
Nothing uploads
The entire rewrite takes place within this tab. So, there is no difference between a client file that contains confidential info and a public file.
The size row is honest
Obfuscation usually makes a program bigger, and the row says by how much. So you can weigh up the trade-off before you commit to it.
Habits That Keep Obfuscated Code Working
Six habits that keep a rewritten file working in production.
- Keep the readable file in version control So the build will run in only one direction. Since no one is supposed to be editing an obfuscated file, a repository which contains only the output has lost its source.
- Never obfuscate a library you ship A consumer reaches your exports by name, so a rename breaks every caller. Hence a published package keeps its real names and its types.
- Leave top-level renaming off by default Renaming a top-level name breaks any other file that calls it, and a classic module puts its functions on window where callers reach them. Since that only shows up at runtime, keep it opt-in and reserve it for modules.
- Keep the source map out of production A source map is a perfect undo, and shipping one alongside the program cancels the whole job. So store the map for crash reporting and serve it from nowhere public.
- Test after obfuscating, not before A safe rename is proved only by the module which does what it is supposed to do. So, the run through should occur at the end of the process (the output) and not at the beginning (the input).
- Say what it is in the build notes A future maintainer who meets an obfuscated file should not have to guess. So a line in the readme about which passes run saves an afternoon.
Six Ways Obfuscation Breaks A Build
Each of these passes a parse and fails in production.
Treating it as security
Look out now. All transformations can be reversed and a dedicated reader can decipher your logical thinking. Thus, when you use obfuscation, it only increases the amount of effort required by readers to understand what you have written and does not protect any content.
Renaming a name somebody else reads
A global the page calls, a callback a host gives, or a name in a server-rendered template. As the outside world is still using the previous spelling, the call falls on empty space.
Renaming names another file calls
A top-level function another file calls by name stops existing under that name. So the call fails at runtime, long after the rename looked fine.
Leaving a source map on the server
The single request to the map will completely undo the entire build. Since the debugger reads from the map, this is an accurate and complete undo.
Trusting it to hide a secret
A key or token that exists within a module is still present in the software program. The browser must locate and read this to use it. So, obfuscating will merely increase the amount of effort required to find the key/token, and nothing more. Thus, secrets should reside on servers.
Obfuscating instead of minifying
They do not represent an option of "better" versus "worse," since they have different objectives. In that order, use the minifier to reduce the amount of bytes used by your code and use the obfuscator to increase the amount of effort required to read the code.
JavaScript Obfuscator Questions
Does this JavaScript obfuscator cost anything?
Indeed. There are no restrictions on how many scripts you can obscure. There are also no limits on how much data you can process, nor is there any content that needs payment.
Will obfuscation make my code secure?
No, and no tool will ever be able to. It makes the module harder to read and doesn’t hide anything from a dedicated reader. Secrets should always be stored on a server, and never included in code that is run in a browser.
What does obfuscation actually change in my code?
At most four things: what the names will be called, where the strings are stored, how the numbers are formatted when outputted, and if the spaces should be removed. The program’s operation remains identical to before.
Will the obfuscator run my code?
Never. The obfuscator processes and rewrites the module, and doesn’t call functions. This means that a code segment that is new to you will not run as long as you have the file open.
Will the obfuscated code still work?
This is what is being parsed, and that is what the final step shows. How it works, though, is another story. So, make sure you run the results through your test suite before release.
Should I rename top-level names?
They are only called if no other code outside of the script calls them. This can happen within a module, or within an IIFE which is safe to use. But, a classic script that defines its functions on the window object would not be safe to use, since there may be other files that call those functions by name.
Will the script get smaller?
Usually not; moving strings into an array and spelling names out can add bytes. The size row reports the change either way, and compacting claws some of it back.
What does encoding numbers as hex do?
It displays each decimal number in its hexadecimal equivalent, so 1000 would appear as 0x3e8. Both numbers are exactly the same, they only look different because the decimal digits no longer appear to be a common number.
Why is there a name prefix field?
Because a helper created by a generator called ’a’ may conflict with a global on the same web page. So, a unique short prefix eliminates this possibility.
Is it possible to reverse the obfuscation?
Not from here. Readers can clean up a renamed file on their own, and they can even fold a string array back together; but, both of those tasks need the reader to do it manually. This is why these two activities will slow down the reader.
Is the script I paste sent to a server?
No, the entire rewritten document is processed within your web browser. This means that a confidential client document will remain strictly on your local computer.
Can I paste a fragment rather than a whole script?
Yes. A single function works, and the rename stays inside it. So you can try a snippet before committing to the whole script.
Will it handle JSX or TypeScript?
Because both of these are based on JavaScript, you will have to compile your code first and then run the obfuscation process on the output of the compilation.
Do I need a source map?
In regards to crash reporting, yes, and it should remain private. Since a served map gives an absolute "undo," maintain it within your own error tracking system and nowhere else in the public domain.
Is obfuscating the same as minifying?
No, minifiers are used to remove extra space from your scripts and use smaller variable names in each script. But, an obfuscator will do this as well, but it also alters the structure of the code, so it will typically take up more memory.
In what order should I minify, obfuscate and validate?
First, minimize; second, obscure; third, verify. Since the verification process will assign names to lines, review the original readable version of your code before performing either of these two operations.
Can it obfuscate a whole folder?
No on this page. At this time only one script can be run on this page and a build tool would be the best way to use a folder.
Does it run on phones too, or only on desktops?
Yes. The panes stack, and the settings wrap into lines. Thus, a fast run can be done off-desk, but a long file will be easier with a keyboard.
Can I download the obfuscated script?
Yes. The download will save the generated code in a JavaScript format, which means you can use the downloaded code directly in your build process without needing to copy and paste.
Is an account or an extension required?
No. It does not need a signup, plugin, or extension to install. You just close the browser window after your build completes.
More Developer Tools That Work Well With This One
Four pages the same job usually leads to.
- JavaScript minifier
This should be run before the next. A minifier reduces byte size and keeps original names, which makes it the least expensive part of the same build process.
- JavaScript validator
At this point you should check the input parse as well as the output parse. Since a syntax error will cause your entire script to fail, it is best to do this checking before shipping.
- Code beautifier
When you encounter a compressed or renamed file that has been created elsewhere, this page will help you read it again. A long continuous line is difficult to follow with your eyes, so the first thing we do is add indentation back into the document.
- CSS minifier
The stylesheet component of the same build. A browser downloads each and every comment and line break so this part of the build should get the same attention as other components.
Raise The Effort Of Reading Your Script
Tick the transforms and paste the script. The script will not run nor upload. The script is checked at each step of the way by the obfuscator before passing the final version to you. This is a "speed bump" for hackers, not a "lock." It does what it does very well, right here.