Is it possible to indent JavaScript code in Notepad++?
Asked Answered
C

5

95

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++?

Copyright answered 2/2, 2012 at 15:38 Comment(1)
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.Lobate
A
64

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

Approver answered 2/2, 2012 at 15:40 Comment(0)
C
199

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:

Coretta answered 6/4, 2014 at 4:40 Comment(4)
Just tried this today. It worked perfectly. Nice simple explanation, thanks.Meridethmeridian
Awesome.. Its working. you can use it offline also. Bye bye JS beautifierKaenel
+10 , I used to do with online beautifier but this one is just perfect!Garfield
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!Hydrargyrum
A
64

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

Approver answered 2/2, 2012 at 15:40 Comment(0)
J
51

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

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

Jeffryjeffy answered 23/3, 2012 at 7:46 Comment(0)
P
7

Use jsbeautifier instead of trying to do it manually.

Pifer answered 2/2, 2012 at 15:38 Comment(0)
H
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

Hindoo answered 2/2, 2012 at 15:41 Comment(3)
Arh, beaten too it. Sorry. Google chrome will do this also cristian-radulescu.ro/article/…Hindoo
Didn't know that trick on chrome, is is useful too, thank youCopyright
@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.Polyp

© 2022 - 2024 — McMap. All rights reserved.