Sign up to save tools and stay up to date with the latest in AI
bg
bg
1

Using LLMs to reverse JavaScript variable name minification

Mar 17, 2024 - thejunkland.com
The blog discusses a new method to reverse minify Javascript using large language models (LLMs) like ChatGPT and llama2, while maintaining the code's semantic integrity. The process involves reversing lossless minification, recreating unimportant data loss, and renaming variables and function names that were lost during minification. The renaming process involves reading the function's body, describing what the function does, and coming up with a fitting name. The LLMs are used for rephrasing and summarizing, while traditional tools like Babel are used for renaming and modifying the code.

The blog also highlights the challenges of controlling LLMs due to their non-deterministic nature, but notes that there are now ways to control the LLM's output to match a desired format. The process of un-minifying Javascript involves unbundling webpack bundles, running the code through transform-beautifier and custom Babel plugins, looping through all variables in the code to generate better names, renaming the variables using Babel, and running a final round of Prettier for whitespace. The tool used for this process, Humanify, is open source and available on Github.

Key takeaways:

  • The blog introduces a novel way to reverse minified Javascript using large language models (LLMs) like ChatGPT and llama2, keeping the code semantically intact.
  • LLMs are used to describe the intent of variables and generate better names based on that description, but they are not used for the actual renaming and modification of the code due to their inherent randomness.
  • The process of un-minifying Javascript involves several steps including unbundling webpack bundles, reversing lossless minification, renaming variables using LLMs and Babel, and ensuring nice whitespace with Prettier.
  • The tool for this process, called Humanify, is open source and available on Github.
View Full Article

Comments (0)

Be the first to comment!