DEV Community

Vladimir Ignatev
Vladimir Ignatev

Posted on • Updated on

Decode obfuscated Javascript code with help of ChatGPT

Back in 2022 Anthony Smith shared a fun tip about code obfuscation in Javascript.


When you tackle analyzing some obfuscated JS code, try out the GPT! Here is how to do this.

Quick tip on decoding obfuscate Javascript code using GPT

  1. Ask to analyze the code and paste the code.
  2. Then ask to rewrite it for better readability!


Here is what I fed to GPT:

Please analyze the following code and tell me what it does? 

function _0x33bc(_0x357a49, _0x4d043b) {
    var _0x3af57c = _0x3af5();
    return _0x33bc = function (_0x33bc59, _0x2d7f6b) {
        _0x33bc59 = _0x33bc59 - 0xac;
        var _0x433c74 = _0x3af57c[_0x33bc59];
        return _0x433c74;
    }, _0x33bc(_0x357a49, _0x4d043b);
var _0x5b0965 = _0x33bc;

function _0x3af5() {
    var _0x16d4f2 = ['2293120DDXwAC', '5tguhIh', 'ExpressJS', '32097acJbHr', '1234303tDdtZs', 'HTML', '51273EoArEE', 'CSS', 'JavaScript', '3214428qqnLuG', 'MongoDB', '40qdyzEo', 'Smith', '252346qcgJWs', '292cvJCiT', 'Anthony', 'PHP', '2392880xWQHuO',...
Enter fullscreen mode Exit fullscreen mode

Then she explained some details, but still it isn't clear what is this code supposed to do.

Now I'm asking for more!.. She flawlessly re-wrote it and now it looks human-friendly! Amazing!

function generateProgrammingLanguages() {
    return ['HTML', 'CSS', 'JavaScript', 'React', 'NodeJS', 'MongoDB', 'ExpressJS', 'PHP'];

function selectLanguage(index) {
    const languages = generateProgrammingLanguages();
    return languages[index];

const person = {
    first_name: 'Anthony',
    last_name: 'Smith',
    occupation: 'Full Stack Developer',
    languages: [
Enter fullscreen mode Exit fullscreen mode

Now the response is very close to sample from Anthony's tip. At least, it is easy to understand this code. Isn't it? Welcome to comments!


Check out the full session in ChatGPT.

Top comments (0)