Lately in my day job I've been troubleshooting ASP.NET pages that use server controls that lean heavily on Javascript.  The kind of Javascript that is stripped and streamlined with zero whitespace or carriage returns.  So to make any sense of it at all I needed a beautifier:

function layoutmouseup() {if ((moving != 0) && (target != 0)) {rearrange(moving, movingcol, target, targetcol);var targ = target;if (movingcol == targetcol && target > moving) {targ = targ - 1;}displaylayout();}moving = 0;movingcol = 0;target = 0;targetcol = 0;}
function layoutmouseup()
{
	if ((moving != 0) && (target != 0))
	{
		rearrange(moving, movingcol...
		var targ = target;
		if (movingcol == targetcol ...
		{
			targ = targ - 1;
		}
		displaylayout();
	}
moving = 0; movingcol = 0; target = 0; targetcol = 0; }
 

After Googling for “javascript beautifier free” I came up with only payware solutions that have more features than I wanted.  I just want a simple way to put crappy Javascript in, and get back stuff that looks reminiscent to the C# I write in Visual Studio.  So I took a half hour and wrote a free beautifier:

http://couponmeister.com/beautify.aspx

Source code is available from the link if you'd like to extend it.  Will work with Java, C++, and C# as well.

Enjoy!

UPDATE: A more recent post about the beautifier is available here.

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Feedback

# Thanks !

Great job, and really useful to me today ! :) 3/27/2006 8:39 PM | Xavier

# Thank you VERY much !

I had to debug a one-line file (3000 caracters). This has been VERY useful. Thanks ! 4/17/2006 8:41 AM | Didier

# re: To satisfy your reverse-engineering cravings: a free online Javascript beautifier

Looks good but it's not currently capturing for-loops, for example:

for(j=1;j<2;j++){doSomething(i);}

At the moment it's splitting the for-loop declaration into several lines due to the semi-colons. 5/15/2006 12:06 AM | Alex

# A few bugs are now fixed

Alex -- Good call on the for() loop issue. I have just fixed that. Also an issue with single vs double quotes around strings. So it's much more reliable now. Plus I converted to using StringBuilder instead of simple string concatenation, and large blocks of script now parse much more quickly.

This will always remain 100% free and open-source. Please tell your friends or blog about it. 7/17/2006 7:21 AM | Lorin

# Also handles obfuscation

One more thing I forgot to mention -- the routine now handles escaped characters that are represented in hexadecimal or octal. So some of the gnarlier obfuscated strings can be made more readable. You're stuck with the crazy variable names though. To clean those up you would have to have a pretty smart parser that knows the scope of variables and can rename them in just the right places.
7/17/2006 8:55 AM | Lorin

# translated to JavaScript/PSPad

I wanted to use the beautifier in the PSPad editor, so I translated the cs-code to JavaScript:

http://triess.de/download/format.zip
7/17/2006 11:49 AM | Stefan Triess

# re: To satisfy your reverse-engineering cravings: a free online Javascript beautifier

Link broken :-( 8/15/2006 12:54 PM | Pete

# re: To satisfy your reverse-engineering cravings: a free online Javascript beautifier

it doesn't handle comments 9/16/2006 3:16 PM | andy

# re: To satisfy your reverse-engineering cravings: a free online Javascript beautifier

Great stuff, thx a million mate! 11/28/2006 10:44 AM | Hamayoun

# Thank you!!

It is a great tool to form the code!! 12/30/2006 1:10 AM | Jan

# re: To satisfy your reverse-engineering cravings: a free online Javascript beautifier

Thanks so much - This is just what I needed! 1/23/2007 9:40 PM | SquadraCorse

# re: To satisfy your reverse-engineering cravings: a free online Javascript beautifier

Code like this
// A line with comment
setTimeout('bbb()',100);
setTimeout("cccc(0)", 100);

becomes:
// A line with comment setTimeout('bbb()',100); setTimeout("cccc(0)", 100);
6/15/2007 6:53 AM | Desislav Kamenov

# re: To satisfy your reverse-engineering cravings: a free online Javascript beautifier

where's the source code??? i need your help plz 7/19/2007 11:00 AM | Jore

# Crashes on AdSense

This code gives a "Index was outside the bounds of the array" error.

http://pagead2.googlesyndication.com/pagead/show_ads.js
10/16/2007 9:38 AM | David Phillips

# re: To satisfy your reverse-engineering cravings: a free online Javascript beautifier

Greate job!
But the source code can't download!
Can please check out the link:
http://hdvforever.com/blog/beautifier.zip 1/20/2008 12:12 AM | Jim

# Got an exception with code menu.js

[IndexOutOfRangeException: Index was outside the bounds of the array.]
System.Text.StringBuilder.get_Chars(Int32 index) +20
beautifier.beautify.endsWith(StringBuilder dst, String check)
beautifier.beautify.doBeautify_Click(Object sender, EventArgs e)
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1292 3/26/2008 9:07 AM | Rayshi02

# re: To satisfy your reverse-engineering cravings: a free online Javascript beautifier

Source code link zip file doesn't work ;) 12/19/2008 6:08 AM | Mehzoh

# re: To satisfy your reverse-engineering cravings: a free online Javascript beautifier

Lately in my day job I've been troubleshooting ASP.NET pages that use server controls that lean heavily on Javascript. The kind of Javascript that is stripped and streamlined with zero whitespace or carriage returns. So to make any sense of it at all I needed a beautifier: 8/12/2009 9:20 AM | ed hardy swimwear

# re: To satisfy your reverse-engineering cravings: a free online Javascript beautifier

ASP.NET is rather dificul tolearn, the source code link zip file wont work 9/22/2009 11:08 AM | Babysitting services

# re: To satisfy your reverse-engineering cravings: a free online Javascript beautifier

very help dul aritvl 11/1/2009 4:23 PM | Watch Animes Online

# re: To satisfy your reverse-engineering cravings: a free online Javascript beautifier

Thanks for the post mate! Great share.
pet meds 11/3/2009 11:25 AM | Janna

# re: To satisfy your reverse-engineering cravings: a free online Javascript beautifier

Lorin, thanks for that one! 11/6/2009 11:33 PM | DDos Protection

# re: To satisfy your reverse-engineering cravings: a free online Javascript beautifier


Nice post,thank you for your sharing.

Frank Gehry has designed and lent his name to this line of
tiffany sterling silver that

includes frank gehry bracelet,frank gehry tiffany rings, necklaces, earrings, cuff links

and more.
11/17/2009 9:45 PM | tiffany necklaces

# re: To satisfy your reverse-engineering cravings: a free online Javascript beautifier

Thanks for the post mate!
Detox Center 11/27/2009 1:21 PM | GerryG

# re: To satisfy your reverse-engineering cravings: a free online Javascript beautifier

Late at night.metin2 yang A dream. 11/30/2009 9:28 PM | aion kinah

# re: To satisfy your reverse-engineering cravings: a free online Javascript beautifier

I converted to using StringBuilder instead of simple string concatenation, and large blocks of script now parse much more quickly.
Places to Visit in Phoenix 12/7/2009 6:32 PM | paul

# re: To satisfy your reverse-engineering cravings: a free online Javascript beautifier

Well Formatting javascript code is not easy.Visual studio 2008 supports javascript code formatting.
Alcohol Rehab Program Seattle Washington 12/9/2009 10:07 AM | Law

# No javascript , us Jquery

It's better to to take health insurance as soon as possible. Generic Zoloft 12/17/2009 12:38 AM | Buy Lasix online

# re: To satisfy your reverse-engineering cravings: a free online Javascript beautifier

So some of the gnarlier obfuscated strings can be made more readable. You're stuck with the crazy variable names though. To clean those up you would have to have a pretty smart parser that knows the scope of variables and can rename them in just the right places.
Statute Of Limitations Malpractice 12/21/2009 12:58 PM | paul

# re: To satisfy your reverse-engineering cravings: a free online Javascript beautifier

There are several reasons but to me the most important is that Bing does not associate your search data with your other Microsoft accounts to build a rich and personally identifying profile of you.
Cheap Nexium 12/23/2009 6:20 AM | Mariya

# re: To satisfy your reverse-engineering cravings: a free online Javascript beautifier

So some of the gnarlier obfuscated strings can be made more readable. You're stuck with the crazy variable names though. To clean those up you would have to have a pretty smart parser that knows the scope of variables and can rename them in just the right places. watch love happens online | harry potter and the half blood prince watch online 12/23/2009 8:13 AM | watch inglourious basterds

# re: To satisfy your reverse-engineering cravings: a free online Javascript beautifier

we like a number of the stuff you have put online about snitterfield like the virtual village. they have started a project of building a village site for snitterfield which you might require to contribute some material or perhaps link back to us from your web pages 12/23/2009 4:10 PM | drept penal

# re: To satisfy your reverse-engineering cravings: a free online Javascript beautifier

25 Feb 2006 ... re: To satisfy your reverse-engineering cravings: a free online Javascript beautifier. very help dul aritvl 11/1/2009 4:23 PM | Watch Animes ...
Road Trip Planner
towe Ski
12/24/2009 2:06 PM | sidkof

# re: To satisfy your reverse-engineering cravings: a free online Javascript beautifier

26 May 2009 ... Coriell Personalized Medicine Collaborative Launches Web Portal. from Business ... The Personalized Medicine Coalition (PMC) released the ...
Road Trip Planner
towe Ski
12/24/2009 2:14 PM | juliajin

# re: To satisfy your reverse-engineering cravings: a free online Javascript beautifier

Plus I converted to using StringBuilder instead of simple string concatenation, and large blocks of script now parse much more quickly. 12/30/2009 7:45 PM | brand clothing

# re: To satisfy your reverse-engineering cravings: a free online Javascript beautifier

Great job but i did use this script in my apps but not be working well. 1/6/2010 2:33 PM | elottery

# re: To satisfy your reverse-engineering cravings: a free online Javascript beautifier

can we use these scripts into Facebooks apps 1/11/2010 12:18 AM | Marketing For Dentists

# re: To satisfy your reverse-engineering cravings: a free online Javascript beautifier

can we use for the face apps 1/11/2010 4:01 PM | No Prescription Online Pharmacy

# re: To satisfy your reverse-engineering cravings: a free online Javascript beautifier

JavaScript Beautifier reformats JavaScript source code to make it more readable. Code beautification involves parsing the JavaScript source code into component structures, such as assignment statements, if blocks, loops, etc., and formatting them in a proper manner. It is quick, easy and free! 1/12/2010 6:36 AM | Cheap Lasix

# re: To satisfy your reverse-engineering cravings: a free online Javascript beautifier

Plus I converted to using StringBuilder instead of simple string concatenation, and large blocks of script now parse much more quickly. 1/13/2010 1:10 PM | Online Dating

# re: To satisfy your reverse-engineering cravings: a free online Javascript beautifier

if blocks, loops, etc., and formatting them in a proper manner. It is quick, easy and free! 1/14/2010 2:26 AM | UGG Classic Tall Boots

# re: To satisfy your reverse-engineering cravings: a free online Javascript beautifier

JavaScript Beautifier reformats JavaScript source code to make it more readable. Code beautification involves parsing the JavaScript source code into component structures, such as assignment statements, if blocks, loops, etc., and formatting them in a proper manner. It is quick, easy and free! better off ted season 2 episode 7 | ncis: los angeles season 1 episode 11 1/15/2010 3:49 AM | bad girls club season 4 episode

# re: To satisfy your reverse-engineering cravings: a free online Javascript beautifier

such as assignment statements, if blocks, loops, etc., and formatting them in a proper manner. It is quick, easy and free 1/17/2010 8:45 PM | bailey button ugg

# re: To satisfy your reverse-engineering cravings: a free online Javascript beautifier

Great job and very much thrilling as well. 1/18/2010 1:49 AM | send flower to Russia

# re: To satisfy your reverse-engineering cravings: a free online Javascript beautifier

Nice code.. We have many source codes in our website.. Feel free to read them all.... 1/18/2010 9:54 AM | Ecommerce development

# re: To satisfy your reverse-engineering cravings: a free online Javascript beautifier

Use javascript is very important, although you need always taking care of those who don't have javascript allowed in their browser... 1/18/2010 9:57 AM | debt consolidation loans

# re: To satisfy your reverse-engineering cravings: a free online Javascript beautifier

Thanks for your great tip 1/20/2010 3:00 AM | Watch Anime Online

# re: To satisfy your reverse-engineering cravings: a free online Javascript beautifier

well worth the read. thank you very much for taking the time to share with those who are starting on the subject. Greetings
1/25/2010 2:48 PM | Online Sports Betting

# re: To satisfy your reverse-engineering cravings: a free online Javascript beautifier

Thanks for the consecutive thing as well. 1/26/2010 7:41 AM | Pharmacy No Prescription

# re: To satisfy your reverse-engineering cravings: a free online Javascript beautifier

java script is great for web building.
2/12/2010 5:49 AM | Projector Lamps

# re: To satisfy your reverse-engineering cravings: a free online Javascript beautifier

link building is best way 2/18/2010 12:41 PM | tanning beds

# re: To satisfy your reverse-engineering cravings: a free online Javascript beautifier

But the source code can't download! criminal minds season 5 episode 16 and american idol season 9 episode 18 3/2/2010 6:54 AM | mercy season 1 episode 15

# re: To satisfy your reverse-engineering cravings: a free online Javascript beautifier

I have never heard of this but this is so good to use. This will definitely benefit me at work.
buffalo mesothelioma lawyer 3/3/2010 11:36 AM | james lee

# re: To satisfy your reverse-engineering cravings: a free online Javascript beautifier

Best deals on Replica Louboutin Shoes at http://www.louboutinknockoffs.com/ they have the best selection of Replica Christian Louboutin Shoes. 3/4/2010 6:41 PM | Christian Louboutin Replica

# re: To satisfy your reverse-engineering cravings: a free online Javascript beautifier

thanks dear i need this code. 3/6/2010 1:52 PM | SEXLEKSAKER

# re: To satisfy your reverse-engineering cravings: a free online Javascript beautifier

By using javascript in Reverse engineering is good technique for debugging.

3/12/2010 1:16 PM | denver construction

# re: To satisfy your reverse-engineering cravings: a free online Javascript beautifier

There are several reasons, but for me the most important is that Bing did not search data associated with your other accounts from Microsoft to create a rich and profile of your personal identification. 3/14/2010 2:49 PM | Hypnosis to Treat Depression

# re: To satisfy your reverse-engineering cravings: a free online Javascript beautifier

A clean and structure code always help!

Watch Paranormal Activity Online 3/16/2010 11:29 PM | View Streams

# re: To satisfy your reverse-engineering cravings: a free online Javascript beautifier

The Formatting javascript code is not easy.Visual studio 2008 supports javascript code formatting. 3/18/2010 1:46 PM | Website Design developers

# re: To satisfy your reverse-engineering cravings: a free online Javascript beautifier

Hi! I read your post about "To satisfy your reverse-engineering cravings: a free online Javascript beautifier" and found it really interesting. Thanks! 3/26/2010 9:33 AM | pharmacy viagra

# Great code

THank you, it was very helpfull and helped me alot. have a great day LÖSVAGINOR 3/29/2010 8:30 AM | LÖSVAGINOR

# re: To satisfy your reverse-engineering cravings: a free online Javascript beautifier

There are several reasons, but for me the most is that Bing search data associated with other accounts from Microsoft to build a rich profile of your personal identification. 3/29/2010 2:31 PM | laptop repairs

# re: To satisfy your reverse-engineering cravings: a free online Javascript beautifier

Am I to handle StringBuilder instead of a simple chain, and in large blocks of script is now much faster. 3/29/2010 4:10 PM | thermal imaging camera

# re: To satisfy your reverse-engineering cravings: a free online Javascript beautifier

reverse engineering basically re fresh the system again. 3/29/2010 5:31 PM | HID KIT

# re: To satisfy your reverse-engineering cravings: a free online Javascript beautifier

She'll find something, she says, and comes back with a box containing a bar of soap, a deodorant, and a bunch of fairly useless food items, from my point of view- lots of candy and cookies and a one-pound can of ham, which, without a refrigerator, I would have to eat all in one sitting. My khakis have a day or two left in them and two clean T-shirts remain until the next trip to a Laundromat, but a question has been raised about the T -shirts. Customers are in fact the major obstacle to the smooth transformation of information into food and food into money - they are, in short, the enemy. 5/20/2010 12:46 AM | printplace review

# re: To satisfy your reverse-engineering cravings: a free online Javascript beautifier

Than you need go tolast chaos gold 6/2/2010 9:51 PM | last chaos gold

# re: To satisfy your reverse-engineering cravings: a free online Javascript beautifier

Great job and very interesting as well. The use javascript is very important. 6/15/2010 6:09 AM | Massagestavar

# re: To satisfy your reverse-engineering cravings: a free online Javascript beautifier

Thank you so much for this informative post.

watch full movie 7/21/2010 7:18 AM | watch full movie

# re: To satisfy your reverse-engineering cravings: a free online Javascript beautifier

I would like to appreciate your blog come from
Replica HERMES Bags 7/27/2010 12:10 AM | Replica COACH Bags

# re: To satisfy your reverse-engineering cravings: a free online Javascript beautifier

there are plenty of people who are facing weight loss issues. I think only thousands of them get successful. Thank god I am one of them as I am using meridia weight loss pills. meridia is a diet pill , I am using meridia from last 6 months and almost loss 5 kg. Its really very nice . you can order meridia 15 mg tablets from online pharmacy. They really offer meridia / reductil tablets at very cheap price. 8/6/2010 1:22 AM | buy meridia online

# re: To satisfy your reverse-engineering cravings: a free online Javascript beautifier

I found so many interesting stuff in your blog especially its discussion. From the tons of comments on your articles, I guess I am not the only one having all the enjoyment here! Keep up the good work. 8/12/2010 4:06 AM | Flowers in Vancouver

# re: To satisfy your reverse-engineering cravings: a free online Javascript beautifier

Thanks for the great post 8/20/2010 1:56 PM | Projector Bulbs

# re: To satisfy your reverse-engineering cravings: a free online Javascript beautifier

I pride to be citizen of the world, so I am also hoping that the Hindu’s class system of “Royal(lords) and peasant (commoner)will change”, so the education level will improve together with the knowledge, virtues and economy.
China had forgotten the past history with Japan. The former Premiere Mr. Deng Xiao Ping , when asked by the Japanese premiere about twenty five years ago.” about the return of the northern island back to China.” Mr. Dan replied:” Slow down, we wouldn’t know how the politics of the world is going to be fifty years from now.” Most recently, Mr. Hu said:” We hope Japan will involve in greater part of the affair of the world. We are happy to see the peaceful path Japan takes since the thank you for sharing :) 8/25/2010 8:27 AM | Soğutma Büyüsü

# re: To satisfy your reverse-engineering cravings: a free online Javascript beautifier

The former Premiere Mr. Deng Xiao Ping , when asked by the Japanese premiere about twenty five years ago.” about the return of the northern island back to China.” Mr. Dan replied:” Slow down, we wouldn’t know how the politics of the world is going to be fifty years from now.” Most recently, Mr. Hu said:” We hope Japan will involve in greater part of the affair of the world. We are happy to see the peaceful path Japan takes since the thank you for sharing 9/4/2010 4:31 AM | Uggs UK

Post a comment





 

 

News


Welcome to my blog.
Here's what we've got on the menu today:

Tag Cloud


Article Categories

Archives

Post Categories

Image Galleries

Syndication: