You can use several tools, online and offline to beautify a Javascript file making it easier to read and edit.
If you already have NodeJS installed, you can use prettier
which is used in various web apps(KaiOS or otherwise) to make the code "pretty". To install it globally:
npm i prettier -g
To use it on some file:
npx prettier --write file.js
or to use it on all files in the current directory, including CSS and HTML to make them pretty:
npx prettier --write .
Use your favourite search engine to find an online tool(e.g. "javascript beautifier")