91

I have some JavaScript code that is written in one line (no carriage returns), it's completely unreadable...

With Notepad++, I tried to replace these characters ({, }, ;) by themselves plus a carriage return, but it still isn't very handy...

Is there a way to do this correctly in Notepad++?

Makyen
  • 31,849
  • 12
  • 86
  • 121
GianT971
  • 4,385
  • 7
  • 34
  • 46
  • I've edited the question to focus on how to do this in NP++, rather than to ask for a software recommendation. And voted to reopen. – StayOnTarget May 10 '19 at 13:27

5 Answers5

191

JSTool is the best for stability.

Steps:

  1. Select menu Plugins>Plugin Manager>Show Plugin Manager
  2. Check to JSTool checkbox > Install > Restart Notepad++
  3. Open js file > Plugins > JSTool > JSFormat
    screenshot

Reference:

Quang Vinh
  • 2,011
  • 2
  • 12
  • 8
  • 1
    Just tried this today. It worked perfectly. Nice simple explanation, thanks. – ScottyG Sep 19 '14 at 17:53
  • 2
    Awesome.. Its working. you can use it offline also. Bye bye JS beautifier – Paresh3489227 Aug 25 '15 at 06:11
  • +10 , I used to do with online beautifier but this one is just perfect! – wpcoder Oct 15 '17 at 14:03
  • Nice. My only gripe is that it appears at the top of the list of Plugins, which I believe is sorted alphabetically by file name of all things. Certainly a much smaller inconvenience than manually formatting source code or copying and pasting into a web page, though! – Ken Lyon May 15 '18 at 19:15
64

I think you want a code beautifier, this one looks quick and easy: http://jsbeautifier.org/

Ryan Doherty
  • 38,580
  • 4
  • 56
  • 63
51

Try the notepad++ plugin JSMinNpp(Changed name to JSTool since 1.15)

http://www.sunjw.us/jsminnpp/

Sun Junwen
  • 1,068
  • 10
  • 20
7

Use jsbeautifier instead of trying to do it manually.

7

Could you use online services like this ?

Update: (as per request)

Google chrome will do this also http://cristian-radulescu.ro/article/pretty-print-javascript-with-google-chrome.html

Sam Greenhalgh
  • 5,952
  • 21
  • 37
  • 2
    Arh, beaten too it. Sorry. Google chrome will do this also http://cristian-radulescu.ro/article/pretty-print-javascript-with-google-chrome.html – Sam Greenhalgh Feb 02 '12 at 15:43
  • Didn't know that trick on chrome, is is useful too, thank you – GianT971 Feb 02 '12 at 15:49
  • @SamGreenhalgh I'd love to see your comment pulled into your answer. It's applies to any webkit browser, and there's no need for an external service. – its_me Jul 21 '12 at 01:47