There is a .js file in which the code is written in 1 line (compressed), but I need to look at it, fix it. In general, how to translate it back into the expanded style?

In SASS, you can substitute the code, choose the style - and everything will turn out, but what to do with JavaScript?

  • one
    jsbeautifier.org is the best online formatter I've ever tried. What text editor do you use? If Sublime Text, I will write down the solution for it. Thank. - Sasha Chernykh
  • Yes, I use sublime, but somehow I still don’t understand how through it - Flayter
  • Now then I will write the answer. - Sasha Chernykh
  • I have already formatted that service, but I'm still waiting - Flayter

1 answer 1

The software, in particular, the unfolding code written in one line, and generally making it convenient for human perception, is called a formatter or beautifier .

Common solution for js

Online JavaScript beautifier . Alternatives can be found on the network, but personally this service completely suits me. At the bottom of the link there is a list of formatter for browsers, text editors, IDE, etc. - choose depending on what you use.

Sublime Text 3 Solution

On Stack Overflow, we recommend the HTMLPrettify plugin (requires preinstallation of the Node.js platform), which I had no problems with using .html and .css ; some of the .js , namely the font files embedded through Cufón , refused to format the plugin correctly. It does not expand js and the tool embedded in Sublime Text 3: select the text by pressing Ctrl + AEditLineReindent .

The js-beautify plugin came up . After installing it in the file that needs to be formatted, you should click somewhere with the right mouse button and select JavascriptBeautify in the drop-down menu. The code will unfold and get a beautiful view.

Before:

js code before js-beautify processing

After:

js code after js-beautify processing

Thank.