Search code examples
javascriptjqueryminifyunminify

How to convert minified to unminified JavaScript by mapping with variables


i have got a lot of way to beautify javascript code. but all of those way of conversions are based on without mapping variable. let see with example of minified js:

!function(a){var b=[],c={init:function(){a(document).ready(c.ready);a(window).on("load",c.load)},ready:function(){},load:function(){setTimeout(function(){console.log(this)},1000)},};c.init()}(jQuery)

now i am looking for a automated tools/system to convert the minified js code to a beautified code where i can map all minified variables (a,b,c ..) to meaningful variables like ($,var1,var2 ...) where i can able to assign mapping of variable like a=$, b=var1, c=var3 and so on. So that i can get a beautified code like

! function($) {

    var var1 = [];

    var var2 = {
        init: function() {

             $(document).ready(var2.ready);
             $(window).on("load", var2.load);
        },
        ready: function() {

        },
        load: function() {
            setTimeout(function() {
                console.log(this);
            }, 1000)
        },
    };

    var2.init();

}(jQuery);

What are the best tools to perform such conversion?


Solution

  • here is the list of online tools that will help you to beautify javascript code. but you will not get the feature to map variables - https://www.cleancss.com/javascript-beautify/ - https://codebeautify.org/jsviewer - https://www.freeformatter.com/javascript-beautifier.html - https://beautifier.io/ - https://www.prettifyjs.net/ - https://jstherightway.org/ - https://prettier.io/playground/ - https://html-cleaner.com/js/